Skip to content

October 20, 2013

Sample Code for Send sms via Bulk SMS API Using PHP

Signup from a bulk sms provider.and modify the code according to that http api link.

<?php
$domain     =     "mydomain.co.in";
$uname      =     "myusername";
$pwd          =     "mypassword";
$to             =     "9999000000";//reciever 10 digit number (use
comma (,) for multiple users. eg: 9999999999,8888888888,7777777777)
$sms         =     "test sms";//sms content
$sender     =     "TESTDEMO";// sender id. this may be a number
$route       =     "A";// sending route
$sms = urlencode($sms);
$sender = urlencode($sender);
// set parameters the API for sending sms
$parameters="uname=$uname&pwd=$pwd&senderid=$sender&to=$to&msg=$sms&route=$route";
// call the Api
$fp = fopen("http://$domain/sendsms?$parameters", "r");
$response = stream_get_contents($fp); // get response of API call
echo "Success : ".$response; exit; // if response is a number...........
// this was the message id returned. save it for delivery report..........
// you can use your own logic and functions for
// your requirement...
?>
Read more from PHP, Web Development