我想使用 PHP 下载 Facebook 网页。我已经尝试了 file_get_contents 和 stream_context_create。我也试过卷曲。但 Facebook 只回复这条信息:
更新您的浏览器 您正在使用 Facebook 不支持的网络浏览器。要获得更好的体验,请访问以下站点之一并获取您首选浏览器的最新版本:
我错过了什么吗?
这是卷曲代码:
$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";