GET方法导致错误

时间:2012-06-10 10:50:12

标签: php get ashx

对不起标题,但我不确定如何调用它。

我注册了一个ssm服务,它可以使用php脚本发送自动短信。 该脚本基本上构建了一个包含所有sms参数的xml字符串(sendername,..)。

然后用它来发送它:

$sms_host = "api.inforu.co.il"; // Application server's URL;  
    $sms_port = 80; // Application server's PORT; 

    ////.... generating query 
    $sms_path = "/SendMessageXml.ashx"; // Application server's PATH; 
    $fp = fsockopen($sms_host, $sms_port, $errno, $errstr, 30); // Opens a socket to the Application server
    if (!$fp){ // Verifies that the socket has been opened and sending the message; 
        echo "$errstr ($errno)<br />\n"; 
        echo "no error";
    } else  {
        $out = "GET $sms_path?$query HTTP/1.1\r\n";
        $out .= "Host: $sms_host\r\n";
        $out .= "Connection: Close\r\n\r\n";

        fwrite($fp, $out);
        while (!feof($fp)){ 
            echo fgets($fp, 128); 
        } 
        fclose($fp); 

如果我粘贴此

,查询就可以了
$url = "http://api.inforu.co.il/SendMessageXml.ashx?" . $query;

直接在浏览器中,然后短信发送。

所以问题是我收到了错误

应用程序中的服务器错误。

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /SendMessageXml.ashx

1 个答案:

答案 0 :(得分:0)

你必须urlencode()你的$query,如果你把它粘贴到浏览器上,浏览器会为你编码,但是当你处理套接字时,你必须自己做。< / p>

相关问题