Facebook has removed the offline_access token functionality, now tokens have to be renewed whenever the user visits your website to keep them active.
Say someone has
use Facebook\FacebookSession;
use Facebook\GraphSessionInfo;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;
use Facebook\FacebookRedirectLoginHelper;
FacebookSession::setDefaultApplication('YOURAPPID', 'SECRET');
$user_accessToken = $_COOKIE['access_token_facebook']
$session = new FacebookSession($user_accessToken);
try {
$session->validate();
} catch (FacebookRequestException $ex) {
// When Facebook returns an error
echo $ex->getMessage();
} catch (\Exception $ex) {
// When validation fails or other local issues
echo $ex->getMessage();
}
if ($session) {
// Exchange token for long token
$longToken = $session->getExchangeToken();
// ... your other stuff
}
Ref: https://developers.facebook.com/docs/facebook-login/access-tokens#pagetokens https://developers.facebook.com/docs/facebook-login/access-tokens#extending