http请求地址为:http://sms.sharera.com:8841/servlet/sendmsg
   现在要用PHP编写一个程序向这个http请求地址post两个参数:number和content,请问如何写?
   请达人给一个例子,最后有一点解释,小弟刚玩PHP不久在此感谢了。。

解决方案 »

  1.   

    因为lz没给分啊用socket的函数可以写
      

  2.   

    <?php
    $fp = fsockopen("sms.sharera.com", 8841, $errno, $error, 10);
    if (!$fp) {
        die($error);
    }
    $data = "number=123&content=test";
    $out = "POST /servlet/sendmsg HTTP/1.1\r\n";
    $out .= "Host: sms.sharera.com\r\n";
    $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $out .= "Content-Length: ". strlen($data) . "\r\n";
    $out .= "\r\n".$data;
    fwrite($fp, $out);
    while (!feof($fp)) {
    echo fgets($fp, 128);
    }
    fclose($fp);
    ?>
      

  3.   

    http://sms.sharera.com:8841/servlet/sendmsg?number=123&content=test