Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Integrate SMS Gateway API with SS

Go to End

5 Posts   6251 Views


Community Member, 3 Posts

28 September 2008 at 4:41am

Edited: 28/09/2008 6:13am

Hello Friends,
I'm seeking for helping hand for building SMS Gateway API Script that will co-exists with

SS and able to send User Input (ie. Sender, PhoneNumber(international format), Message Text,

Message Type (Text only/Flash SMS etc.) using SS to SMS Gateway API @

here is copy of PHP Script which has to be worked with SS.
( I have purchased one bulk sms pack from in php script i'm going to have my

account details. later on when user will post info this script should send URL to sms

gateway @


$sndr = '';
$phonenum ='';
$message = '';
$sndr = $_POST['sender'];
$phonenum = $_POST['PhoneNumber'];
$message = $_POST['text'];

$res = sendsms ($sndr,$phonenum,$message);

// Call this function when ever you wish to Send SMS
function sendsms($sndr,$mobile,$text)
	$host = "";
	$request = ""; 					//initialize the request variable
	$param["user"] = "username"; 		//	this is the username of your SMS 

	$param["password"] = "password"; 	//this is the password of our SMS account
	$param["text"] = substr($text,0,159); 	//this is the message that we want to send
	$param["PhoneNumber"] = $mobile; 		//these are the recipients of the 

	if ($tmp=="9198" || $tmp=="9194" || $tmp=="9199" || $tmp=="9192" || $tmp=="9197")
		if ($sndr != NULL)
		$sender = $sndr;
		$sender = "";			// SenderID for GSM and TATA
		$sender= "919860609000";		// SenderID for CDMA (Reliance0
	$param["sender"] = $sender;
	$param["track"] = "1";
	foreach($param as $key=>$val) 	// Traverse through each member of the param array
	  	$request.= $key."=".urlencode($val); //we have to urlencode the values
	  	$request.= "&"; //append the ampersand (&) sign after each paramter/value 

	$request = substr($request, 0, strlen($request)-1); //remove the final ampersand 

sign from the request
	$script = "/sendsmsv2.asp";
	$request_length = strlen($request);
	$method = "POST"; 
//	if ($method == "GET") 
//		{
		//$script .= "?$request";
//		}
	//Now comes the header which we are going to post. 
	$header = "$method $script HTTP/1.1\r\n";
	$header .= "Host: $host\r\n";
	$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
	$header .= "Content-Length: $request_length\r\n";
	$header .= "Connection: close\r\n\r\n";
	$header .= "$request\r\n";

	//Now we open up the connection
	$socket = @fsockopen($host, 80, $errno, $errstr); 
	if ($socket) //if its open, then...
	  	fputs($socket, $header); // send the details over
			$output=$output.fgets($socket); //get the results 

	if ($pos===false)
		return(0);  // SMS Not Successful
		return(1); // SMS Was successful

	//Check Result of Sending SMS
	if ($res==1)
	echo "SMS to $phonenum was successful...";
	echo "$track";
	echo "SMS to $phonenum was not successful...";


SMS Gateway API As follows:

The post either via GET or POST needs to be done on

The variables to be used are:

user -> Your username on the website

password -> Your password on the website

sender -> Alphanumeric/Number SenderID from your approved list of SenderID's to be used for GSM Recipients

sendercdma -> Number SenderID from your approved list of SenderID's to be used for CDMA Recipients

PhoneNumber -> Mobile number of the recipients. for multiple recipients enter numbers seperated by comma.

group -> (optional) The name of the group you wish to send message to. (Groups can be created and managed on the website.)

text -> The text of the message. (Charged 1 unit for 160 characters per recipient.)

flash = 1/0 -> (1) If the message should flash directly on the screen/(0)For standard SMS.

track = 1 -> if you wish to Track the delivery status of the message. (Optional)

A sample post to send sms would be like

Simple Text Messages:,919370119223&track=1

Message Submitted
Credits Consumed: 2
Balance Credits: 98
Mobile=919822012345 MsgId=1177855328
Mobile=919370119223 MsgId=1177855329


Features Expected:
1] i want to give registered users to send SMS thro this script.
2] i want to keep copy of every sms in database with username. (optional)
3] i want to count every users total message count. (160 chars par sms)

Please someone help me out..

Thank you very much for your precious time.. :)


Community Member, 400 Posts

28 September 2008 at 5:07pm

this will be great I will make a widget out of this ;)
so people will be able to send SMS useing their blogs


Community Member, 3 Posts

2 October 2008 at 11:52pm

when it will be available? can you share your more ideas about it? or help me with it? i need some clues to get into development..


Community Member, 201 Posts

3 October 2008 at 12:09am

We've actually done a few implementations of this in the past. The main reason this code hasn't made it's way into the open source branch is because each implementation is quite different, as much of the code needs to be specific to the API's of the SMS gateway you choose.

So in order to make a useful OS widget out of this, you'll need to pick a SMS gateway which can be used by developers all over the world (one of the reasons again we haven't released any code is we've done integration with relatively obscure SMS gateways historically)


Community Member, 3 Posts

3 October 2008 at 12:27am

If widget is not possible, can you please help me with custom hack to make it work with my current SS installation? i want to make this service available for free to my small community.