无法使file_get_contents工作 [英] Unable to file_get_contents to work
问题描述
我正在使用facebook graph api来检索登录的用户信息.
I am using facebook graph api, to retrieve logged in user's info.
$facebookdata = json_decode(file_get_contents('https://graph.facebook.com/me?access_token=' . $fb_accesstoken . '&fields=name,picture'),true);
现在,当我 var_dump 时,我将得到null.我确实尝试转到url https://graph.facebook.com /me?access_token = ACCESS_TOKEN& fields = id,名称,图片.它显示名称和photourl.
Now When I var_dump I get null. I did try to goto url https://graph.facebook.com/me?access_token=ACCESS_TOKEN&fields=id,name,picture. It shows the name and photourl.
感谢您的帮助.
推荐答案
检查是否已启用 allow_url_fopen
您的php.ini
.否则请修改,因为那样一来file_get_contents将无法从http URL读取.
Check if allow_url_fopen
is enabled in your php.ini
. Otherwise adapt, because file_get_contents will not be able to read from http URLs then.
第二,提高您的 error_reporting
级别.它应该已经告诉你了.
Second, raise your error_reporting
level. It should have told you so.
如果未收到错误消息,则可能阻止了PHP user_agent
的访问.还有另一个php.ini设置.另外,也可以尝试 curl
.
If you get no error message, then access with the PHP user_agent
might be blocked. There is another php.ini setting for that. Also alternatively, just try curl
.
这篇关于无法使file_get_contents工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!