SMS from PHP script | Search |
NowSMS Support Forums ⬆ NowSMS Support - SMS Issues ⬆ Archive through June 24, 2009 ⬆ |
◄ ► |
Author | Message | |||
Idris Akano New member Username: Iris Post Number: 1 Registered: 04-2009 |
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 |
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 |