I want to download a Facebook web page using PHP. I've tried file_get_contents along with stream_context_create. I've also tried Curl. But Facebook is returing only this message:
Update Your Browser You’re using a web browser that isn’t supported by Facebook. To get a better experience, go to one of these sites and get the latest version of your preferred browser:
Am I missing anything?
Here is the Curl code:
$url="https://www.facebook.com/media/set/?set=a.189662541197403.1073741845.188398434657147&type=1&l=a8755a774e";
$custom_headers = array();
$custom_headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$custom_headers[] = "Pragma: no-cache";
$custom_headers[] = "Cache-Control: no-cache";
$custom_headers[] = "Accept-Language: en-us;q=0.7,en;q=0.3";
$custom_headers[] = "Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7";
$ch = curl_init();
$useragent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1";
curl_setopt($ch, CURLOPT_USERAGENT, $useragent); // set user agent
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_headers);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,20);
curl_setopt($ch, CURLOPT_TIMEOUT, 40); //timeout in seconds
$txResult = curl_exec($ch);
$statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print "$txResult";