示例#1
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;
 }