Esempio n. 1
0
 /**
  * Ensure the request token has been verified and an access token received.
  *
  * @return	void
  */
 protected function _check_token()
 {
     parent::_check_token();
     $token = $this->_token;
     if (isset($token->attributes) and is_array($token->attributes)) {
         $attributes = $token->attributes;
         $oauth_session_handle = Arr::get($attributes, 'oauth_session_handle');
         $oauth_expires_in = Arr::get($attributes, 'oauth_expires_in');
         // Get the date the token was last updated
         $date_updated = 0;
         $model = $this->_model;
         if ($model instanceof Jelly_Model) {
             $date_updated = $model->date_updated;
         }
         if (!empty($oauth_session_handle) and $date_updated + $oauth_expires_in < time()) {
             // Refresh the access token
             $token = $this->_refresh_access_token($oauth_session_handle, array('token_key' => $token->key, 'token_secret' => $token->secret));
             if (isset($token) and $this->is_valid_token($token)) {
                 $success = $this->_update_token($token);
             }
         }
     }
 }