I try to get extended long-lived access token with
$facebook->setExtendedAccessToken();
$access_token = $facebook->getAccessToken();
After looking SDK I found that setExtendedAccessToken() function is setting long-lived access token in
protected static $kSupportedKeys =
array('state', 'code', 'access_token', 'user_id');
with
$this->setPersistentData(
'access_token', $response_params['access_token']
);
and getAccessToken() is returning short-lived access token from
protected $accessToken
so what is the purpose of setExtendedAccessToken() since it does not return anything?
@Julian. Thank you so much for the inspiration here. I was able to make this work without changing any of the core FB api files.
What happens is, the setExtendedAccessToken
call sends the value to setPersistentData
which then sends it into session via constructSessionVariableName
.
So if we get it out of session, and then set it into the facebook object, we're all set.
Here is my code:
// ask for the extended token and get it from session ...
$facebook->setExtendedAccessToken();
$access_token = $_SESSION["fb_".FB_APP_ID."_access_token"];
// now set it into the facebook object ....
$facebook->setAccessToken($access_token);
// now our fb object will use the new token as usual ...
$accessToken = $facebook->getAccessToken();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With