public function toRequest($url,$param)
{
$urlInfo = parse_url($url);
$host = $urlInfo['host'];
$path = $urlInfo['path'];
$query = isset($param)? http_build_query($param): '';
$port = 80;
$errno = 0;
$errstr = '';
$timeout = 10;
$fp = fsockopen($host,$port,$errno,$errstr,$timeout);
$out = "POST " . $path . " HTTP/1.1\r\n";
$out .= "host:" . $host . "\r\n";
$out .= "content-length:" . strlen($query). "\r\n";
$out .= "content-type:application/x-www-form-urlencoded\r\n";
$out .= "connection:close\r\n\r\n";
$out .= $query;
ignore_user_abort(true);// 忽略客户端断开
set_time_limit(0);
fputs($fp,$out);
fclose($fp);
}
网友评论