How to handle PHP Facebook expiration exception?

I enter Facebook from the Javascript SDK. On the server side, I use the PHP SDK for authentication. I am using the function FacebookJavaScriptLoginHelper () . The problem i'am encounters, after logging out I get this error:

Fatal error: exception exception "Facebook \ FacebookSDKException" with the message "Session expired or is invalid for this application." in this line $ session-> validate ('App_Id', 'Secret');

if (isset($_SESSION['token'])) {
$session = new FacebookSession($_SESSION['token']);
try {
    $session->validate('App_Id', 'Secret');
} catch(FacebookAuthorizationException $e) {
    unset($session);
    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();
}
}


if (!isset($session)) {
try {
    $helper = new FacebookJavaScriptLoginHelper();
    $session = $helper->getSession();        
    $_SESSION['token'] = $session->getToken();
} catch(FacebookRequestException $e) {
    unset($session);
    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();
}
}

Here are my two points of interest:

  • How to deal with the end of the session and update it when the user is logged in?
  • FacebookAuthorizationException: " ". , . , , javascript php . ?

Facebook , . .

+4

All Articles