嗨fsockopen
已被停用,但curl
不是。
有人可以将此翻译为curl
版本吗?我曾经尝试过,但是很难过。
$sock = fsockopen("http://facebook.com" , 80);
if(FALSE == $sock ) {
echo "Ms Here";
return;
}
fwrite($sock, $header );
while ($line = fread($sock, 25000)){
echo $line;
}
fclose($sock);
感谢。
答案 0 :(得分:2)
尝试:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://facebook.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close'));
$response = curl_exec($ch);
curl_close($ch);