Reputation: 187
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]
what's my fault?
Upvotes: 0
Views: 1334
Reputation: 2529
First, the access token with the offline_access
permission can become invalid if :
You can read a blog post from Facebook about how to handle expired tokens.
Then, you should not :
graph.facebook.com/[function]...
, but use the Facebook PHP SDK functions to make API calls.$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 !
Upvotes: 2