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 @ sms.alertzap.com.
here is copy of PHP Script which has to be worked with SS.
( I have purchased one bulk sms pack from alertzap.com 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 @ sms.alertzap.com
(e.g. http://sms.alertzap.com/sendsmsv2.asp?user=username&password=mypassword&sender=Internet&sendercdma=919860609000&text=This+is+a+sample+sms&PhoneNumber=919822012345,919370119223&track=1)
<?php
$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 = "sms.alertzap.com";
$request = ""; //initialize the request variable
$param["user"] = "username"; // this is the username of your SMS
account
$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
message
$tmp=substr($mobile,0,4);
if ($tmp=="9198" || $tmp=="9194" || $tmp=="9199" || $tmp=="9192" || $tmp=="9197")
{
if ($sndr != NULL)
$sender = $sndr;
else
$sender = "SwiftGet.net"; // SenderID for GSM and TATA
}
else
$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
pair
}
$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
while(!feof($socket))
{
$output=$output.fgets($socket); //get the results
}
fclose($socket);
}
$pos=strpos($output,"Submitted");
if ($pos===false)
return(0); // SMS Not Successful
else
return(1); // SMS Was successful
}
//Check Result of Sending SMS
if ($res==1)
{
echo "SMS to $phonenum was successful...";
echo "$track";
}
else
{
echo "SMS to $phonenum was not successful...";
}
?>
[\code]
SMS Gateway API As follows:
The post either via GET or POST needs to be done on
http://sms.alertzap.com/sendsmsv2.asp
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 alertzap.com 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:
http://sms.alertzap.com/sendsmsv2.asp?user=username&password=mypassword&sender=Internet&sendercdma=919860609000&text=This+is+a+sample+sms&PhoneNumber=919822012345,919370119223&track=1
Output:
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.. :)