コード例 #1
0
ファイル: base_facebook.php プロジェクト: nrobillard/regency
  /**
   * Analyzes the supplied result to see if it was thrown
   * because the access token is no longer valid.  If that is
   * the case, then the persistent store is cleared.
   *
   * @param $result array A record storing the error message returned
   *                      by a failed API call.
   */
  protected function throwAPIException($result) {
    $e = new FacebookApiException($result);
    switch ($e->getType()) {
      // OAuth 2.0 Draft 00 style
      case 'OAuthException':
        // OAuth 2.0 Draft 10 style
      case 'invalid_token':
        $message = $e->getMessage();
      if ((strpos($message, 'Error validating access token') !== false) ||
          (strpos($message, 'Invalid OAuth access token') !== false)) {
        $this->setAccessToken(null);
        $this->user = 0;
        $this->clearAllPersistentData();
      }
    }

    throw $e;
  }
コード例 #2
0
 /**
  * Analyzes the supplied result to see if it was thrown
  * because the access token is no longer valid.  If that is
  * the case, then we destroy the session.
  *
  * @param $result array A record storing the error message returned
  *                      by a failed API call.
  */
 protected function throwAPIException($result)
 {
     $e = new FacebookApiException($result);
     switch ($e->getType()) {
         // OAuth 2.0 Draft 00 style
         case 'OAuthException':
             // OAuth 2.0 Draft 10 style
         // OAuth 2.0 Draft 10 style
         case 'invalid_token':
             // REST server errors are just Exceptions
         // REST server errors are just Exceptions
         case 'Exception':
             $message = $e->getMessage();
             if (strpos($message, 'Error validating access token') !== false || strpos($message, 'Invalid OAuth access token') !== false || strpos($message, 'An active access token must be used') !== false) {
                 $this->destroySession();
             }
             break;
     }
     throw $e;
 }
コード例 #3
0
 public static function HandelException(FacebookApiException $objFBException)
 {
     switch ($objFBException->getMessage()) {
         case 'Error validating access token: The session has been invalidated because the user has changed the password.':
             throw new MFBFBPermissionsException();
             break;
         case 'Error validating access token: Session does not match current stored session. This may be because the user changed the password since the time the session was created or Facebook has changed the session for security reasons.':
             throw new MFBFBPermissionsException();
             break;
         default:
             throw $objFBException;
             break;
     }
 }