i want download facebook web page using php. i've tried file_get_contents along stream_context_create. i've tried curl. facebook returing message:
update browser you’re using web browser isn’t supported facebook. better experience, go 1 of these sites , latest version of preferred browser:
am missing anything?
here 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";
use api instead?
the data url mentioned can retrieved one:
http://graph.facebook.com/?id=189662541197403
also, reduces entire code line :
json_decode(file_get_contents('http://graph.facebook.com/?id=189662541197403'));
Comments
Post a Comment