GET 方法会导致错误


GET method causes an error

对不起标题,但我不确定如何称呼它。

我已注册到 ssm 服务,该服务可以使用 php 脚本发送自动短信。该脚本基本上构建了一个包含所有 SMS 参数(发件人名称,..)的 XML 字符串。

然后它使用它来发送它:

$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

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