Tuesday, July 12, 2016

SMS GATEWAY INTEGRATION IN PHP

How to Send Sms through sms gateway using php

First of all you need details of your sms gateway
i.e

  • sms gateway url
  • username 
  • password
  • 'type // default set as TEXT
  • sender //senderid to be approved from sms provider
these information will be provided by your SMS gateway provider.

once you get these details you can now send sms using php 

First configure mobile to send sms and content of sms,

$qs="&mobile=".$mobilenum."&message=".urlencode($smscontent)."";

Now make a URL which used to send sms and concat the string to url as below

$url="http://your-sms-gateway-link/sendsms.php?username=yourusername&password=yourpassword&type=TEXT&sender=SENDERID".$qs;

Now using CURL send sms


function firecurl($u){
        $curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $u);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HEADER, false);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}

// fire sms

$sendsms = firecurl($url);

That's All
Thanks

No comments:

Post a Comment