2016-07-29 174 views
1

我在我的网站http://searchisback.com上有一个php脚本,用于从用户的公共页面检索一些文本。这个用来抓取我的Facebook页面的代码不再那么做了。任何想法为什么?file_get_contents停止工作

$url = "http://facebook.com/michael.morgenstern"; 
$options = array(
    'http'=>array(
    'method'=>"GET", 
    'header'=>"Accept-language: en\r\n" . 
       "Cookie: foo=bar\r\n" . 
       "User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n" // i.e. An iPad 
) 
); 

$context = stream_context_create($options); 

$file = @file_get_contents($url, false, $context); 

echo $file; 

谢谢!

迈克尔

+0

刮痧脸书是反对他们的托管(除非你有他们的表达事先书面同意) - 所以你一直在做错,即使它在“工作”。你需要使用API​​。 – CBroe

回答

1

删除@它抑制警告

PHP Warning: file_get_contents(http://facebook.com/michael.morgenstern) 
HTTP request failed! HTTP/1.1 404 Not Found 
+0

谢谢!它看起来像Facebook返回404响应此查询,但不响应浏览器查询。不知道如何得到它。 – mikeyla85

-1

尝试https,而不是http

https://www.facebook.com/michael.morgenstern 

问候(和一些好东西来填补30个字符)