<?php
function sendsms($usr, $pwd, $orig, $dest, $txt, $dlrurl = "") {
$url = "https://secure.devsmsexpert.com/smsg/sms.mes";
if ($dlrurl != "") {$dlrurl = "&dreceipt_url=$dlrurl";}
$params = "usr=$usr&pwd=$pwd&from=$orig&to=$dest&type=text&route=d&txt=".urlencode($txt);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params.$dlrurl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$returned = curl_exec($ch);
curl_close($ch);
$ret = explode("\n", $returned); $ret = explode("|", $ret[1]);
print("Full response: $returned<br><br>-----<br><br>error code: ".$ret[0]."<br>error text: ".$ret[1]."<br>submission reference: ".$ret[2]."<br><br>-----<br><br>");
if ($ret[0] == 0) {print("Success<br>");} else {print("Fail (".$ret[1].")<br>");}
}
//set to your delivery receipt handler URL and add id if needed
$dlrurl = "http://www.mydomain.com/dlr_handler.php?userid=myid";
//set XXX and YYY to your SMS Expert username and password
sendsms("XXX", "YYY", "SMSExpert", "447123456789", "hello", $dlrurl);
?>
|