Esempio n. 1
0
 /**
     @param $a the token passed back from the oAuth Provider, typically $_GET['oauth_token']
 */
 public function getAccessToken($tok)
 {
     $uri = self::ACCESS_TOKEN_URI;
     $arg = array('oauth_token' => $tok['oauth_token'], 'oauth_consumer_key' => $this->_oauth_client_id, 'oauth_signature_method' => 'PLAINTEXT', 'oauth_signature' => '&' . $tok['oauth_token_secret']);
     // radix::dump($uri);
     // radix::dump($arg);
     $res = radix_http::post($uri, $arg);
     // radix::dump($res);
     parse_str($res['body'], $x);
     return $x;
     // radix::dump($x);
     // exit;
     // $arg = array(
     //     'client_id' => $this->_oauth_client_id,
     //     'client_secret' => $this->_oauth_client_secret,
     //     'grant_type' => 'authorization_code',
     //     'redirect_uri' => $a['redirect_uri'],
     //     'code' => $a['code'],
     // );
     // $res = radix_http::get($uri . '?' . http_build_query($arg));
     // radix::dump($res);
     // $ret = json_decode($res['body'],true);
     try {
         $res = $this->_oauth->getAccessToken($uri);
         $this->_oauth->setToken($res['oauth_token'], $res['oauth_token_secret']);
         // radix::dump($res);
         // exit;
         return $res;
     } catch (Exception $e) {
         radix::dump($this->_oauth->debugInfo);
         return false;
     }
     return $ret;
 }
Esempio n. 2
0
 /**
     @param $code the OAuth2 Code
     @param $page the Redirect to URI
     @see https://developers.google.com/accounts/docs/OAuth2WebServer
 */
 function auth_token($code, $page)
 {
     $uri = 'https://accounts.google.com/o/oauth2/token';
     $arg = array('code' => $code, 'client_id' => $this->_client_id, 'client_secret' => $this->_client_sk, 'redirect_uri' => $page, 'grant_type' => 'authorization_code');
     // POST it
     $ret = radix_http::post($uri, $arg);
     return $ret;
 }
Esempio n. 3
0
 /**
     @param $a the token passed back from the oAuth Provider, typically $_GET['oauth_token']
 */
 public function getAccessToken($opt)
 {
     // $uri = self::ACCESS_TOKEN_URI;
     if (empty($opt['code'])) {
         $opt['code'] = $_GET['code'];
     }
     $arg = array('client_id' => $this->_oauth_client_id, 'client_secret' => $this->_oauth_client_secret, 'grant_type' => 'authorization_code', 'code' => $opt['code'], 'redirect_uri' => $opt['redirect_uri']);
     // $uri = $uri; . '?' . http_build_query($arg);
     $res = radix_http::post(self::ACCESS_TOKEN_URI, $arg, array('User-Agent: ' . self::USER_AGENT));
     if ($res['info']['content_type'] == 'application/json') {
         $res = json_decode($res['body'], true);
         if (!empty($res['access_token'])) {
             $this->_access_token = $res['access_token'];
         }
     }
     return $res;
 }
Esempio n. 4
0
 /**
     @param $a the token passed back from the oAuth Provider, typically $_GET['oauth_token']
 */
 public function getAccessToken($arg)
 {
     $uri = self::ACCESS_TOKEN_URI;
     //        try {
     //            $res = $this->_oauth->getAccessToken($uri);
     //            // radix::dump($res);
     //        } catch (Exception $e) {
     //            radix::dump($this->_oauth->debugInfo);
     //            return false;
     //        }
     //        return $res;
     $arg = http_build_query(array('grant_type' => 'authorization_code', 'client_id' => $this->_oauth_client, 'client_secret' => $this->_oauth_client_secret, 'code' => $_GET['code'], 'redirect_uri' => $arg['redirect_uri']));
     $res = radix_http::post($uri, $arg);
     $res = json_decode($res['body'], true);
     // if ($res['info']['http_code'] == 200) {
     // } else
     return $res;
 }
Esempio n. 5
0
 /**
     Execute POST
 */
 public function post($api, $arg)
 {
     // Patchup URI
     $uri = $this->fixURI($api, $arg);
     $this->_stat['post']++;
     $res = radix_http::post($uri, $arg);
     $ret = json_decode($res['body'], true);
     // radix::dump($ret);
     return $ret;
 }