【发布时间】:2016-01-20 00:03:20
【问题描述】:
我正在尝试从URL 获取数据。它包含 Facebook 用户的好友列表。我必须pass fbid and access-token。它会return friend list。
这里是网址:
<?php
$url = "https://graph.facebook.com/$fbid/friends?access_token=$fb_accesstoken";
?>
但是这个URL 包含错误:
{
"error": {
"message": "Error validating access token: Session does not match current stored session. This may be because the user changed the password since the time the session was created or Facebook has changed the session for security reasons.",
"type": "OAuthException",
"code": 190,
"error_subcode": 460,
"fbtrace_id": "BSpC5i0A6Oo"
}
}
所以我把条件写成这样:
<?php
if(!strpos($url, 'error')) {
$data = file_get_contents($url);
// further process.
} else {
$data = array();
}
?>
我可以理解给出的错误,但我也为此设置了条件,但它仍然给了我相同的条件。 我该如何解决这个问题?
【问题讨论】:
-
不是“包含错误”的 URL,而是您在请求该 URL 时得到的 响应。检查 URL 是否包含文本
error因此没有任何意义。
标签: php facebook url file-get-contents