<?php
function whatsapp($text,$isd_code,$mobile_num,$images_name,$images_path,$caption,$button_arr)
{

        if($isd_code=='')
        {
            $isd_code ='91';
        }

        if($button_arr=='')
        {
              $button_arr ='{
                    
                             }';
        }
        

        $num = $isd_code.$mobile_num;

        $curl = curl_init();

        curl_setopt_array($curl, array(
          CURLOPT_URL => 'http://www.wa.smsidea.com/api/v1/sendButtonMessage',
          CURLOPT_RETURNTRANSFER => true,
          CURLOPT_ENCODING => '',
          CURLOPT_MAXREDIRS => 10,
          CURLOPT_TIMEOUT => 0,
          CURLOPT_FOLLOWLOCATION => true,
          CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
          CURLOPT_CUSTOMREQUEST => 'POST',
          CURLOPT_POSTFIELDS =>'{
            "key": "7cad715257034b6fa9b8b543e509f7f7",
            "to": "'.$num.'",
            "url": "'.$images_path.'",
            "filename": "'.$images_name.'",
            "title": "'.$text.'",
            "caption": "'.$caption.'",
            "IsUrgent":"true",
            "buttons": [
                  
                    '.$button_arr.'
            ],
            "isUrgent": "false"
        }',
          CURLOPT_HTTPHEADER => array(
            'Content-Type: application/json'
          ),
        ));

        $response = curl_exec($curl);

        curl_close($curl);
        //echo $response;
}     

//Send Images Code By Nayan Patani 14-02-2023 5:52 PM

function whatsapp_images_send($text,$isd_code,$mobile,$img_name,$img_path)
{

    if($isd_code=='')
        {
            $isd_code ='91';
        }

  $num = $isd_code.$mobile; 

  $curl = curl_init();
  curl_setopt_array($curl, array(
     CURLOPT_URL => 'http://www.wa.smsidea.com/api/v1/sendImage',
     CURLOPT_RETURNTRANSFER => true,
     CURLOPT_ENCODING => '',     
     CURLOPT_MAXREDIRS => 10,
     CURLOPT_TIMEOUT => 0, 
     CURLOPT_FOLLOWLOCATION => true,      
     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
     CURLOPT_CUSTOMREQUEST => 'POST',
     CURLOPT_POSTFIELDS =>
        '{
         "key": "7cad715257034b6fa9b8b543e509f7f7",
         "to": "'.$num.'",
         "url": "'.$img_path.'",
         "filename": "'.$img_name.'",
         "caption" : "'.$text.'",
         "isUrgent" : "false",
         "isDeleteAfterSend" : "false",
         "isGroupMsg" : "false",
         "ExpiryTime" : "00:00:00",
         "IsFailMessage" : "false",
         "SenderId" : "AB-111213",
         "ContentTemplate" : "Hello. Good Morning",
         "SendingMessageType" : "0",
         }',
    CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
));

$response = curl_exec($curl);
curl_close($curl);
//echo $response;
}


                                                   
?>