public function userInfo()
 {
     $recinfo = Openbiz::$app->getSessionContext()->getVar($this->type . '_access_token');
     $postfields = array('access_token' => $recinfo['oauth_token'], 'format' => 'json');
     $user = json_decode(OAuthUtil::Curl_Post($this->userUrl, $postfields), true);
     if (!$user) {
         return false;
     }
     $user['id'] = $user['userid'];
     $user['type'] = $this->type;
     $user['uname'] = $user['username'] . $this->suffix;
     return $user;
 }
Example #2
0
 function callback()
 {
     //请求参数
     $postfields = array('grant_type' => 'authorization_code', 'client_id' => $this->akey, 'client_secret' => $this->skey, 'code' => $_REQUEST['code'], 'redirect_uri' => $this->callBack);
     $token = json_decode(OAuthUtil::Curl_Post($this->tokenUrl, $postfields), true);
     if ($token['access_token']) {
         $recinfo['oauth_token'] = $token['access_token'];
         $recinfo['oauth_token_secret'] = '';
         $recinfo['access_token_json'] = $token;
         Openbiz::$app->getSessionContext()->setVar('alitao_access_token', $recinfo);
         $userInfo = $this->userInfo();
         $this->check($userInfo);
     } else {
         throw new Exception('验证非法!');
         return false;
     }
 }