Send sms from msg91 sms gateway by using php.
I am creating a simple function. It's simple and easy to integrate.
</php
function send_sms_msg91($message,$phone2)
{
$senderid=777777;
$default_msg=$message." Send By : YOUR COMPANY ";
$authKey="Your--authKey";
$mobileNumber=$phone2;
$senderId="Your--SenderID";
$message=urlencode($default_msg);
$route="4";
$postData = array(
'authkey' => $authKey,
'mobiles' => $mobileNumber,
'message' => $message,
'sender' => $senderId,
'route' => $route
);
$url="https://control.msg91.com/api/sendhttp.php";
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData
));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($ch);
if(curl_errno($ch))
{
echo 'error:' . curl_error($ch);
}
curl_close($ch);
return $output;
}
$message="My MSG";
$phone2="8574785478";
send_sms_msg91($message,$phone2)
?>
Get the latest news and updates by signing up to our daily newsletter.We won't sell your email or spam you !