简体   繁体   English

不活动后,Facebook API OAuthException

[英]Facebook API OAuthException after inactivity

My Facebook app runs fine initially. 我的Facebook应用最初运行良好。 But after a certain amount of inactivity, I start getting the following error: 但是经过一定程度的不活动之后,我开始出现以下错误:

Fatal error: Uncaught OAuthException: An active access token must be used to query information about the current user. thrown in /home/streetof/public_html/wp-content/mu-plugins/facebook-php-sdk/src/base_facebook.php on line 1106

I'm confused because the user is still logged into Facebook, as well as my Wordpress site (which has integrated FB loggin). 我很困惑,因为用户仍然登录到Facebook以及我的Wordpress网站(已集成FB登录)。

I can resolve it by clearing the browser's cookies and logging in/out of the current Facebook account. 我可以通过清除浏览器的cookie并登录/注销当前Facebook帐户来解决该问题。

I've isolated where the error is thrown. 我隔离了引发错误的位置。 I'm using the PHP Facebook SDK. 我正在使用PHP Facebook SDK。 The line of code that triggers the error looks like this: 触发错误的代码行如下所示:

$friends = $facebook->api('/me/friends?fields=name,first_name,last_name,id,work,education');

Any suggestions as to why this is happening? 关于为什么发生这种情况有什么建议吗?

Looks like your access token simply has expired - short-lived access tokens are valid for about one to two hours by default. 看来您的访问令牌已过期-默认情况下,短暂的访问令牌有效期约为一到两个小时。

You could either get a long-lived one – https://developers.facebook.com/roadmap/offline-access-removal/ describes how to do it – or if the user is still interacting with your page, you can call FB.getLoginStatus client-side, that will also refresh the token. 您可能会获得一个长寿的帐户-https: //developers.facebook.com/roadmap/offline-access-removal/描述如何执行-或者如果用户仍在与您的页面进行交互,则可以致电FB。 getLoginStatus客户端,也将刷新令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM