Wednesday, 1 April 2015

Send SMS Using CURL

$_REQUEST['mobile']='9952472946';

 $_REQUEST['message']='template message';

sendSMS($_REQUEST['mobile'],$_REQUEST['message']);

function sendSMS($numbers = FALSE, $msg = FALSE){
       
        $msg = urlencode($msg);
        $remove = array("\n", "\r\n", "\r",";",",,",",,,");
        $numbers = str_replace($remove, ',',$numbers);
        $numbers = str_replace($remove, ',',$numbers);


        $from='Ashok'; // Need to approval this name
               $url="http://myvaluefirst.com/smpp/sendsms?username=<usernme>&password=<password>&to=".$numbers."&from=".$from."&text=".$msg."";
//SYNTAX      
//http:"//<SMS_Service_URL>/api/web2sms.php?workingkey=<API_KEY>&to=<MOBILENUMBER>&sender=<SENDERID>&message=<MESSAGE>";
       
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $store = curl_exec ($ch);
        curl_close ($ch);
        return $store;
   
}


No comments:

Post a Comment