示例#1
0
 public function get_user_info(Access $token)
 {
     $t = urlencode($token->access_token);
     $user = Load::url($this->url_access(), array('http' => array('method' => "GET", 'header' => "Accept-language: en\r\n" . "Authorization: Bearer " . $t . "\r\n")));
     $user = json_decode($user);
     // Create a response from the request
     return array('id' => $user->id, 'name' => $user->name);
 }
示例#2
0
 /**
  * load some required files
  */
 function init()
 {
     parent::init();
     Load::file(base_path() . 'modules/oauth/libraries/sina/SaeTOAuthV2.php');
     $row = $this->member_get_oauth_type($this->type);
     if (!$row->id) {
         exit('access deny');
     }
     $this->oauth_id = $row->id;
     $this->app_key = $row->key1;
     $this->app_secret = $row->key2;
     $this->url = host() . url('oauth/' . $this->type . '/return');
     session_start();
 }
示例#3
0
 /**
  * load some required files
  */
 function init()
 {
     parent::init();
     $row = $this->member_get_oauth_type($this->type);
     if (!$row->id) {
         exit('access deny');
     }
     $this->oauth_id = $row->id;
     $this->app_key = $row->key1;
     $this->app_secret = $row->key2;
     $this->url = host() . url('oauth/' . $this->type . '/return');
     Load::file(base_path() . 'modules/oauth/libraries/twitter-async/EpiCurl.php');
     Load::file(base_path() . 'modules/oauth/libraries/twitter-async/EpiOAuth.php');
     Load::file(base_path() . 'modules/oauth/libraries/twitter-async/EpiTwitter.php');
     $this->auth = new \EpiTwitter($this->app_key, $this->app_secret);
 }
示例#4
0
 function actionReturn($code)
 {
     $postdata = array('client_id' => $this->app_key, 'redirect_uri' => urlencode($this->url), 'client_secret' => $this->app_secret, 'code' => $_GET['code'], 'grant_type' => 'authorization_code');
     $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => Arr::query($postdata)));
     $data = json_decode(Load::url(Taobao::url_access_token(), $opts));
     $access_token = $data->access_token;
     if ($access_token) {
         try {
             $me['id'] = $data->taobao_user_id;
             $me['name'] = $data->taobao_user_nick;
             $r = $this->member_get_third_set_user($me, $this->oauth_id, $access_token);
             flash('success', __('login success'));
             $this->redirect(return_url());
         } catch (OAuthException $e) {
             flash('error', __('login error'));
             $this->redirect(return_url());
         }
     }
     exit;
 }