SMS from PHP script

SMS from PHP script SearchSearch
Author Message
Idris Akano
New member
Username: Iris

Post Number: 1
Registered: 04-2009
Posted on Thursday, April 23, 2009 - 03:06 pm:   

I need to send sms with the gateway from php script and would like to route the message through a particular sim card from a series of sim card modem connected to the gateway. I use a function 'SendSMS ($host, $port, $username, $password, $phoneNoRecip, $msgText)' which does not dictate which modem sends the SMS. The function code is this '$fp = fsockopen($host, $port);
if (!$fp) {
echo "errno: $errno \n";
echo "errstr: $errstr\n";
return $result;
}

fwrite($fp, "GET /?Phone=" . rawurlencode($phoneNoRecip) . "&Text=" . rawurlencode($msgText) . " HTTP/1.0\n");
if ($username != "") {
$auth = $username . ":" . $password;
$auth = base64_encode($auth);
fwrite($fp, "Authorization: Basic " . $auth . "\n");
}
fwrite($fp, "\n");

$res = "";

while(!feof($fp)) {
$res .= fread($fp,1);
}
fclose($fp);


return $res;'}
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 685
Registered: 08-2008
Posted on Monday, April 27, 2009 - 08:17 pm:   

Hi,

You would need to modify the script to pass an additional parameter.

The following link talks about those parameters:

http://blog.nowsms.com/2008/07/routing-sms-messages-to-specifc-smsc.html

In short, you need to either include a "&Sender=" parameter to indicate the phone number associated with the modem that you want to send via. Or, if you make some additional configuration settings, you can use a "&SMSCRoute=" parameter.

Assume that you add a "$sender" parameter to the SendSMS function like this:

SendSMS ($host, $port, $username, $password, $phoneNoRecip, $msgText, $sender)

If you do that, you can modify the line of code that builds the URL to include this parameter like this:

fwrite($fp, "GET /?Phone=" . rawurlencode($phoneNoRecip) . "&Sender=" . rawurlencode($sender) . "&Text=" . rawurlencode($msgText) . " HTTP/1.0\n");

--
Des
NowSMS Support