Exemple #1
0
 public function getAccess($token, $secret, $verifier)
 {
     $code = JRequest::getVar('code');
     $params = array('client_id' => parent::getAppId(), 'redirect_uri' => $this->callback, 'client_secret' => parent::getApiSecret(), 'code' => $code);
     $token = parent::_oauthRequest(parent::getUrl('graph', '/oauth/access_token'), $params);
     $token = str_ireplace('access_token=', '', $token);
     // Get the expiry time and remove it from the token
     $parts = explode('&expires=', $token);
     $expires = '';
     if (count($parts) > 1) {
         $token = $parts[0];
         $expires = $parts[1];
     }
     $obj = new stdClass();
     $obj->token = $token;
     $obj->secret = 'facebook';
     $obj->params = '';
     $obj->expires = $expires;
     return $obj;
 }
Exemple #2
0
 /**
  * Exchanges the request token with the access token
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function getAccess($verifier = false)
 {
     // Get the code from request
     $code = $this->input->get('code', '', 'default');
     $params = array('client_id' => $this->apiKey, 'redirect_uri' => $this->redirect, 'client_secret' => $this->apiSecret, 'code' => $code);
     $token = parent::_oauthRequest(parent::getUrl('graph', '/oauth/access_token'), $params);
     // Split the response because it will be access_token=xxx&expires=xxx
     $token = explode('&', $token);
     if (!isset($token[0])) {
         return false;
     }
     // Get the access token
     $access = $token[0];
     $expires = isset($token[1]) ? $token[1] : '';
     // Remove unecessary codes
     $access = str_ireplace('access_token=', '', $access);
     // If the expiry date is given
     if ($expires) {
         $expires = str_ireplace('expires=', '', $expires);
         // Set the expiry date with proper date data
         $expires = EB::date(strtotime('now') + $expires)->toSql();
     }
     $obj = new stdClass();
     $obj->token = $access;
     $obj->secret = true;
     $obj->expires = $expires;
     $obj->params = '';
     return $obj;
 }