Facebook access_token 为空
我正在尝试获取好友列表,但收到此错误:
Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /server/url/base_facebook.php on line 970
这是我正在使用的代码:
$facebook = new Facebook(array(
'appId' => $appID,
'secret' => $appSecret,
'cookie' => true, // enable optional cookie support
));
$result = $facebook->api('/me/friends/',array('access_token' => $facebook->access_token));
这是我在 $facebook 变量中返回的数据:
Facebook Object
(
[appId:protected] => 220........
[apiSecret:protected] => 2162e6c1b771......
[user:protected] =>
[signedRequest:protected] =>
[state:protected] => 894ad3b36c2ebdcbcf6d4f110641dd4f
[accessToken:protected] =>
[fileUploadSupport:protected] =>
)
由于某种原因,access_token 为空。 本来好好的,突然就停了…… 该应用程序已经拥有权限,并且我正在使用最新的 PHP SDK v3.0.1
请帮助我...我对这个问题快疯了...
谢谢, 酒吧。
I'm trying to get friends list and I get this error:
Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /server/url/base_facebook.php on line 970
This is the code I'm using:
$facebook = new Facebook(array(
'appId' => $appID,
'secret' => $appSecret,
'cookie' => true, // enable optional cookie support
));
$result = $facebook->api('/me/friends/',array('access_token' => $facebook->access_token));
Here's the data I get back in the $facebook variable:
Facebook Object
(
[appId:protected] => 220........
[apiSecret:protected] => 2162e6c1b771......
[user:protected] =>
[signedRequest:protected] =>
[state:protected] => 894ad3b36c2ebdcbcf6d4f110641dd4f
[accessToken:protected] =>
[fileUploadSupport:protected] =>
)
For some reason the access_token is empty.
It worked fine and suddenly stopped...
The app already has the permissions and I'm using the latest PHP SDK v3.0.1
Please help me... I'm going crazy with this issue...
Thanks,
Bar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来您需要首先解析签名的请求,这是 iframe 应用程序还是网站?
如果它是 iframe 应用程序并且用户已经授权,
请尝试此操作。
这将解析签名的请求。
在你获得数据 var_dump 后,你将在其中看到 oauth_token....
it seems like u need to parse the signed request first is this an iframe app or a website?
if it's an iframe app and the user already authorized
try this.
this will parse the signed request.
after u get the data var_dump it and in it u will see the oauth_token....
您应该在构造函数中添加
$this->load->library('facebook');
。You should add
$this->load->library('facebook');
in constructor .您需要将 SDK 升级到 v3.0:
https://github.com/facebook/php-sdk< /a>
编辑:由于您使用的是 v.3.0,您的构造是错误的.. 构造函数不再有 $cookie 参数。我建议修改文档。
You need to upgrade your SDK to v3.0:
https://github.com/facebook/php-sdk
Edit: Since you are using v.3.0 your construct is wrong.. there is no more $cookie parameter for constructor. I suggest revising documentation.