Facebook API登录错误-验证访问令牌的会话已过期


Facebook API Login Error - Session has expired validating access token

我正在记录Facebook登录错误,有时我会看到:

OAuthException: Error validating access token: 
Session has expired on Friday, 29-Apr-16 14:00:00 PDT. 
The current time is Friday, 29-Apr-16 14:38:54 PDT.

是什么原因造成的?我想有人上了网站,生成了代码,38分钟后他点击登录,代币过期了。我该如何防止这种情况发生?

我的代码是这样的:

$fbUser = $facebook->getUser();
if ($fbUser)
{
   try
   {
      // We're logged in!
      $user_profile = $facebook->api('/me');  
   }
   catch (FacebookApiException $e)
   {
      // Oh no, an error :(
      error_log($e);
      $fbUser = null;
   }
}
if ($fbUser) 
{
  try
  {
    $facebook_id = $facebook->getUser();
    $facebook_me = $facebook->api('/me');
    session->set('facebook_me', $facebook_me);
  } 
  catch (FacebookApiException $e)
  {
    error_log($e);
  }
}
else
{
   $facebook_me = $session->value('facebook_me');
}
    Please Used this code. This code is working in my web.
    $fbconfig['appid' ] =   "your_app_id";
    $fbconfig['secret']    =    "your_secret_key";
    $fbconfig['baseurl']   =    "your_redirect_url"; 
    $user                   =   null; //facebook user uid      
    // Create our Application instance.
    $facebook = new Facebook(array('appId'  => $fbconfig['appid'],'secret' => $fbconfig['secret'],'cookie' => true,));
    //Facebook Authentication part
    $user       = $facebook->getUser();
    // We may or may not have this data based   
    $loginUrl   = $facebook->getLoginUrl (
        array (
            'scope'         => 'email,user_birthday,user_location,user_work_history,user_about_me,user_hometown',
            'redirect_uri'  => $fbconfig['baseurl']
        )
    );
    $logoutUrl  = $facebook->getLogoutUrl();
    if ($user) {
      try {
        // Proceed knowing you have a logged in user who's authenticated.
        $user_profile =  $facebook->api('/me?fields=id,first_name,last_name,email,gender,locale,picture');
          echo "<pre>";print_r($user_profile);die;
       }  catch (FacebookApiException $e) {
        //you should use error_log($e); instead of printing the info on browser
        d($e);  // d is a debug function defined at the end of this file
        $user = null;
      }
  }