php如何发送get或者post请求????
php如何发送get或者post请求
比如我现在要向localhost/webcounter/reinform.aspx发送一个post请求应该如何做呢
我用如下代码
$target="/webcounter/ReInform.aspx";//目标文件URL
$domain="localhost";//网站域名
$post_data="uid=3&webSiteID=1®UserName=dd®Time=2005-4-7 15:45:44®Ip=127.0.0.1®Os=ddklf®Browser=dfdf&ac=dddd";//传递的数据
$fp=fsockopen($domain,80);
$out = "GET ".$target."?".$post_data." HTTP/1.1\r\n";
$out .= "Host: localhost\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
运行老是提示我
这个东西
HTTP/1.1 400 Bad Request Content-Type: text/html Date: Tue, 27 Dec 2005 12:25:17 GMT Connection: close Content-Length: 20
Bad Request
郁闷死了 高手教教偶哈