2012-03-04 62 views
0

我得到的错误错误试图检索从Facebook社交图谱API

警告数据:的file_get_contents(https://graph.facebook.com/me?fields=id,name,picture)功能.file-get-contents]:无法打开流:HTTP请求失败!在尝试从Facebook图形API检索用户数据时,HTTP/1.0 400错误请求在/home/schoolda/public_html/fblogin.php在线36

。我已成功验证并授权我的应用,但我不知道如何检索授予的数据。感谢您的任何建议。

回答

1

您需要将auth令牌包含在您的api请求中。

尝试:

file_get_contents(https://graph.facebook.com/me?fields=id,name,picture&access_token=FACEBOOK_ACCESS_TOKEN) 
2

除了身份验证令牌,你可能想尝试添加使用error_reporting到的file_get_contents:

$val = stream_context_create(array('error_reporting' => TRUE)); 

和的file_get_contents的第三放慢参数使用$val

为什么?因为那样你可以回应结果,看看为什么Facebook说“不”。当api发生错误时,Facebook会将错误答案发送回您的服务器。
file_get_contents然后在默认情况下假设您的请求根本不起作用。