用法例:
post('127.0.0.1','/test.php','a=asdfsdfsdf&b=kjhdsfkjhsdkjf');
function post($host,$path,$data)
{
$fp = fsockopen($host, 80);
fputs($fp,"POST $path HTTP/1.1\r\n");
fputs($fp,"Host: $host\r\n");
fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp,"Content-length: " . strlen($data) . "\r\n");
fputs($fp, "User-Agent: MSIE\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);
$buf='';
while (!feof($fp)) {
$buf .= fgets($fp,128);
}
fclose($fp);
return $buf;
}
阅读(1696) | 评论(2) | 转发(0) |