Facebook PHP SDK Error validating access token -


starting thinkdiff.net tutorial have built simple test page (local env) facebook login/logout link.if logged in want echo out fb user api.

im using latest facebook php sdk (v.2.1.2).

it seems work when logout receive exception:

facebookapiexception object ( [result:protected] => array     (         [error] => array             (                 [type] => oauthexception                 [message] => error validating access token: session invalid because user logged out or because auth.expiresession invoked.             )      )  [message:protected] => error validating access token: session invalid because user logged out or because auth.expiresession invoked. [string:exception:private] =>  [code:protected] => 0 [file:protected] => c:\wamp\www\fb\facebook.php [line:protected] => 543 [trace:exception:private] => array     (         [0] => array             (                 [function] => _graph                 [class] => facebook                 [type] => ->                 [args] => array                     (                         [0] => /me                     )              )          [1] => array             (                 [file] => c:\wamp\www\fb\facebook.php                 [line] => 492                 [function] => call_user_func_array                 [args] => array                     (                         [0] => array                             (                                 [0] => facebook object                                     (                                         [appid:protected] => 1819654718*****                                         [apisecret:protected] => a2fccb8e93638b50c8d6b2**********                                         [session:protected] =>                                          [signedrequest:protected] =>                                          [sessionloaded:protected] => 1                                         [cookiesupport:protected] => 1                                         [basedomain:protected] =>                                          [fileuploadsupport:protected] =>                                      )                                  [1] => _graph                             )                          [1] => array                             (                                 [0] => /me                             )                      )              )          [2] => array             (                 [file] => c:\wamp\www\fb\fb.php                 [line] => 33                 [function] => api                 [class] => facebook                 [type] => ->                 [args] => array                     (                         [0] => /me                     )              )      )  [previous:exception:private] =>  ) 

this test page code

$fbconfig['appid']  = "18196**********";      $fbconfig['api']  = "5c6910be575e4e688ac6d**********";      $fbconfig['secret']  = "a2fccb8e93638b50c8d6b2**********";   try {             include_once "facebook.php";  }      catch(exception $o) {           echo '<pre>';           print_r($o);           echo '</pre>';      }      // create our application instance.      $facebook = new facebook(array('appid'  => $fbconfig['appid'],'secret' =>    $fbconfig['secret'],'cookie' => true));         $session = $facebook->getsession();        $fbme = null;      // session based graph api call.      if (!empty($session))  {          d($session);   try    {              $uid = $facebook->getuser();              $fbme = $facebook->api('/me');          }    catch (facebookapiexception $e)    {                d($e);          }     }       function d($d) {          echo '<pre>';          print_r($d);          echo '</pre>';      }    if ($fbme)  {      $logouturl = $facebook->getlogouturl();    echo"<a href='{$logouturl}'>logout</a>";   d($fbme); }  else  {      $loginurl = $facebook->getloginurl(array('req_perms' => 'email,read_stream,user_birthday'));    echo"<a href='{$loginurl}'>login</a>"; } 

thanks

luca

i try manually clearing session on logout. put parameter on return url, or use different return url, , this:

$facebook->destroysession(); 

the problem session cookie persists after user logged out. when user returns page trying use expired session make requests. luck.


Comments