with the old (2.x) SDK I used this to log someone with offline_access:
$session = array
(
'uid' => $userdata['fb_uid'],
'sig' => $userdata['fb_sig'],
'access_token' => $userdata['fb_access_token']
);
$facebook->setSession($session);
In the new SDK this function doesnt exist anymore. I think I need to login using:
setPersistentData($key, $value)
but this function is protected and I dont know what ‘code’ is? Do I need this to log the user in or not? And what’s going on with ‘sig’? Don’t I need this anymore?
Hope someone already figured this out because the documentation really doesn’t help!
With the Facebook PHP SDK v3 (see on github), it is pretty simple. To log someone with the
offline_accesspermission, you ask it when your generate the login URL. Here is how you do that.Get the offline access token
First you check if the user is logged in or not :
If he is not, you generate the “Login with Facebook” URL asking for the
offline_accesspermission :And then display the link in your template :
Then you can retrieve the offline access token and store it. To get it, call :
Use the offline access token
To use the offline access token when the user is not logged in :
And now you can make API calls for this user :
Hope that helps !