CodeIgniter Forums
Sending message to a mobile number via fsockopen - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Sending message to a mobile number via fsockopen (/showthread.php?tid=21552)



Sending message to a mobile number via fsockopen - El Forum - 08-13-2009

[eluser]tochie[/eluser]
Hello,

This is my problem. I want to send a sms message via a host on another domain. I'm supposed to call a page and send variables, then get a response on the status of message I sent. The error message i get says: "Bad Request".

This is my code:

Code:
$sms_host = 'sms.abc.com';       //sms processing gateway
$str = "/abc/abc.asp?";      //path to script  
$str .= "username=abc&";             //the required parameters >> downwards
$str .= "password=abc&";
$str .= "message=testing&";          
$str .= "mobile=3667348829&";
$str .= "sender=CallBackNow&";
$str .= "type=0";

$request = "GET " . $str . " HTTP/1.1\r\n";  
$request .= 'Host: '.$sms_host.' \r\n';
$reply = "";  

$fp = fsockopen($sms_host, 80, $errno, $errstr, 30);
if (!$fp)
{
    echo "$errstr ($errno)<br />\n";
}
else
{
    fwrite($fp, $request);
    
    while (!feof($fp)) {
        $reply =  fgets($fp, 128);
    }
    
    fclose($fp);
}

Any suggestions, Please?

Thanks