Reputation: 201
Hi fsockopen
has been disabled for me, but curl
isn't.
Please can someone translate this to curl
version? I have tried but got stumped.
$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);
Thanks.
Upvotes: 0
Views: 51
Reputation: 100175
Try:
$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);
Upvotes: 2