facebook offline_access error
to access users info when they are offline, the user grants offline_access and I store them by this :
$session=$facebook->getSession();
if($session)
{
$access_token=$session['access_token'];
}
$qq=sprintf("insert into `tokens`(`uid`,`access_token`) values ('%s','%s')",$myid,$access_token);
$res1=mysql_query($qq);
but when I try to use graph.facebook.com to collect information from them , it sometimes work and some times doesn't and gives me this error :
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
i use graph.facebook.com/[function]?access_token=[the access token saved in DB]
开发者_StackOverflow社区what's my fault?
First, the access token with the offline_access
permission can become invalid if :
- the user de-authorizes your app in his privacy settings
- the user changes his password
You can read a blog post from Facebook about how to handle expired tokens.
Then, you should not :
- make API urls directly with URLs, like you do when you call
graph.facebook.com/[function]...
, but use the Facebook PHP SDK functions to make API calls. - use the version of the PHP SDK you are using (
$facebook->getSession()
is from v2.x) is deprecated, that might be the causes of your problems.
Here is an answer on Stackoverflow about how to handle offline_access
access tokens with the Facebook PHP SDK v3.x.
Hope that helps !
精彩评论