My Facebook app runs fine initially. 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).
I can resolve it by clearing the browser's cookies and logging in/out of the current Facebook account.
I've isolated where the error is thrown. I'm using the 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.