I try to get extended long-lived access token with
$facebook->setExtendedAccessToken();
$access_token = $facebook->getAccessToken();
@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();