PHP

SMS Scripts - PHP

Shreeweb provides you with some ready-made scripts that are available to help you connect to our gateway through your chosen programming language. These scripts all work with the HTTP API. Click here ot Contact Us and try our service.

Send SMS with PHP:

Use the PHP code below to send SMS via the Shreeweb SMS Gateway. Simply Contact Us for an HTTP API account, and you will receive an test account with free credits to try our service.

Code Sample:

<?
$user = "user";
$password = "password";
$baseurl ="http://sms.shreeweb.com/sendmsg";
$text = urlencode("This is an example message");
$to = "123456890";
// auth call
$url = "$baseurl/http/auth?user=$user&password=$password";
// do auth call
$ret = file($url);
// split our response. return string is on first line of the data returned
$sess = split(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url = "$baseurl/http/sendmsg?session_id=$sess_id&to=$to&text=$text";
// do sendmsg call
$ret = file($url);
$send = split(":",$ret[0]);
if ($send[0] == "ID")
echo "success
message ID: ". $send[1];
else
echo "send message failed";
} else {
echo "Authentication failure: ". $ret[0];
exit();
}
?>

Last Updated on Monday, 09 November 2009 17:47
 
Copyright © 2013 Shreeweb | All Rights Reserved.