This question already has an answer here:
- php: Get html source code with cURL 4 answers
I'm trying to get the HTML source from a website using PHP, I've tried the following code and it works correctly for google.com
and other websites, but it does not work for facebook.com
What am I missing?
<?php
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'www.facebook.com');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
$query = htmlentities($query);
echo $query;
?>
</div>