Last active
August 29, 2015 14:26
-
-
Save FeroVolar/31261e36438ffc90e60d to your computer and use it in GitHub Desktop.
Sending SMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function send_sms($mobile,$msg) | |
{ | |
$authKey = "XXXXXXXXXXX"; | |
date_default_timezone_set("Asia/Kolkata"); | |
$date = strftime("%Y-%m-%d %H:%M:%S"); | |
//Multiple mobiles numbers separated by comma | |
$mobileNumber = $mobile; | |
//Sender ID,While using route4 sender id should be 6 characters long. | |
$senderId = "IKOONK"; | |
//Your message to send, Add URL encoding here. | |
$message = urlencode($msg); | |
//Define route | |
$route = "template"; | |
//Prepare you post parameters | |
$postData = array( | |
'authkey' => $authKey, | |
'mobiles' => $mobileNumber, | |
'message' => $message, | |
'sender' => $senderId, | |
'route' => $route | |
); | |
//API URL | |
$url="https://control.msg91.com/sendhttp.php"; | |
// init the resource | |
$ch = curl_init(); | |
curl_setopt_array($ch, array( | |
CURLOPT_URL => $url, | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_POST => true, | |
CURLOPT_POSTFIELDS => $postData | |
//,CURLOPT_FOLLOWLOCATION => true | |
)); | |
//Ignore SSL certificate verification | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
//get response | |
$output = curl_exec($ch); | |
//Print error if any | |
if(curl_errno($ch)) | |
{ | |
echo 'error:' . curl_error($ch); | |
} | |
curl_close($ch); | |
} | |
?> | |
<?php | |
$message = "Hello World"; | |
$mobile = "918112998787"; | |
send_sms($mobile,$message); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment