<?php
$user = "user";
$pass = "pass";
$sms_from = "SMSGLOBAL";
$sms_to = "61409317436";
$sms_msg = "hello world";
// send sms
// returns false if failed
// returns $smsglobalmsgid if successful
function gw_send_sms($user,$pass,$sms_from,$sms_to,$sms_msg)
{
$msg_type = "text";
$unicode = "0";
$query_string = "http-api.php?action=sendsms&user=".$user."&password=".$pass;
$query_string .= "&from=".rawurlencode($sms_from)."&to=".rawurlencode($sms_to);
$query_string .= "&clientcharset=ISO-8859-1&";
$query_string .= "text=".rawurlencode(stripslashes($sms_msg)) . "&detectcharset=1";
$url = "http://www.smsglobal.com.au/".$query_string;
$fd = @implode ('', file ($url));
if ($fd)
{
// got response from server
$response = split("; Sent queued message ID:",$fd);
$response1 = split(":",$response[0]);
$smsglobal_status = trim($response1[1]);
$response2 = split(":",$response[1]);
$smsglobalmsgid = trim($response2[1]);
if ($smsglobal_status=="0")
{
// message sent successfully
$ok = $smsglobalmsgid;
}
else
{
// gateway will issue a pause here and output will be delayed
// possible bad user name and password
$ok = false;
}
}
else
{
// no contact with gateway
$ok = false;
}
return $ok;
}
$msgid = gw_send_sms($user,$pass,$sms_from,$sms_to,$sms_msg);
if ($msgid)
{
echo "<br> sent ok <br>";
echo "message id is $msgid<br>";
}
else
{
echo "<br> not sent <br>";
}
?>
|