拉取用户信息(需scope为 snsapi_userinfo):第四步
@param $openId
@param string $oauth2AccessToken
@param string $lang
@return array|bool
439915
public function getSnsUserInfo($openId, $oauth2AccessToken, $lang = 'zh_CN')
    {
        $result = $this->httpGet(self::WEHCAT_SNS_USER_INFO_PREFIX, [
            'access_token' => $oauth2AccessToken,
            'openid' => $openId,
            'lang' => $lang
        ]);
        return !array_key_exists('errcode', $result) ? $result : false;
    }
111234
public function getAuthorizeUserInfo($state = 'authorize', $scope = 'snsapi_base')
    {
        $request = Yii::$app->request;
        if (($code = $request->get('code')) && $request->get('state') == $state) {
            return $this->getOauth2AccessToken($code);
        } else {
            Yii::$app->getResponse()->redirect($this->getOauth2AuthorizeUrl($request->getAbsoluteUrl(), $state, $scope));
            Yii::$app->end();
        }
    }
156027
def get_user_info(self, user_id, lang="zh_CN"):
        
        return self.get(
            url="https://api.weixin.qq.com/cgi-bin/user/info",
            params={
                "access_token": self.token,
                "openid": user_id,
                "lang": lang
            }
        )
801947
public static UserTagGetResult userTagGet(String access_token,Integer tagid,String next_openid){
		String json = String.format("{\"tagid\":%d,\"next_openid\":\"%s\"}",tagid,next_openid==null?"":next_openid);
		HttpUriRequest httpUriRequest = RequestBuilder.post()
										.setHeader(jsonHeader)
										.setUri(BASE_URI+"/cgi-bin/user/tag/get")
										.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
										.setEntity(new StringEntity(json,Charset.forName("utf-8")))
										.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,UserTagGetResult.class);
	}
133034
public function refreshOauth2AccessToken($refreshToken, $grantType = 'refresh_token')
    {
        $result = $this->httpGet(self::WECHAT_OAUTH2_ACCESS_TOKEN_REFRESH_PREFIX, [
            'appid' => $this->appId,
            'grant_type' => $grantType,
            'refresh_token' => $refreshToken
        ]);
        return !array_key_exists('errcode', $result) ? $result : false;
    }
673817
public function vaildAccessToken(string $access_token, string $open_id)
    {
        $data = [
            'access_token' => $access_token,
            'openid' => $open_id,
        ];
        $url = self::WECHAT.'auth?'.http_build_query($data);
        $data = $this->curl->get($url);

        return Response::json($data);
    }
1079034
public function select(array $openids, string $lang = 'zh_CN')
    {
        return $this->httpPostJson('cgi-bin/user/info/batchget', [
            'user_list' => array_map(function ($openid) use ($lang) {
                return [
                    'openid' => $openid,
                    'lang' => $lang,
                ];
            }, $openids),
        ]);
    }
98663
protected static function cgi_user_get_uri($access_token,$next_openid){
        $param = [
            'access_token' => $access_token,
            'next_openid'  =>$next_openid
        ];
        return self::CGI_USER_GET_URI.http_build_query($param);

    }
275900
public function usersInfo(array $openId) {
        $data = [];
        foreach ($openId as $item) {
            if (is_array($item)) {
                $data = $openId;
                break;
            }
            $data[] = [
                'openid' => $item,
                'lang' => 'zh-CN'
            ];
        }
        return $this->getUsersInfo()->parameters([
                'user_list' => $data
            ])->json();
    }
1035007
public function getAccessToken($appid = '', $appsecret = '', $token = '')
    {
        if (!$appid || !$appsecret) {
            list($appid, $appsecret) = array($this->appid, $this->appsecret);
        }
        if ($token) {
            return $this->access_token = $token;
        }
        $cache = 'wechat_access_token_' . $appid;
        if (($access_token = Tools::getCache($cache)) && !empty($access_token)) {
            return $this->access_token = $access_token;
        }
        # 检测事件注册
        if (isset(Loader::$callback[__FUNCTION__])) {
            return $this->access_token = call_user_func_array(Loader::$callback[__FUNCTION__], array(&$this, &$cache));
        }
        $result = Tools::httpGet(self::API_URL_PREFIX . self::AUTH_URL . 'appid=' . $appid . '&secret=' . $appsecret);
        if ($result) {
            $json = json_decode($result, true);
            if (!$json || isset($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                Tools::log("Get New AccessToken Error. {$this->errMsg}[{$this->errCode}]", "ERR - {$this->appid}");
                return false;
            }
            $this->access_token = $json['access_token'];
            Tools::log("Get New AccessToken Success.", "MSG - {$this->appid}");
            Tools::setCache($cache, $this->access_token, 5000);
            return $this->access_token;
        }
        return false;
    }
1206905
public static BaseResult groupsMembersUpdate(String access_token,String openid,String to_groupid){
		String groupJson = "{\"openid\":\""+openid+"\",\"to_groupid\":"+to_groupid+"}";
		HttpUriRequest httpUriRequest = RequestBuilder.post()
										.setHeader(jsonHeader)
										.setUri(BASE_URI+"/cgi-bin/groups/members/update")
										.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
										.setEntity(new StringEntity(groupJson,Charset.forName("utf-8")))
										.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
	}
219226
public function getUserInfo($openId, $lang = 'zh_CN')
    {
        $result = $this->httpGet(self::WECHAT_USER_INFO_GET, [
            'access_token' => $this->getAccessToken(),
            'openid' => $openId,
            'lang' => $lang
        ]);
        return !array_key_exists('errcode', $result) ? $result : false;
    }
984161
public function connectOauth2($options)
    {
        $token = false;

        // source oauth provider
        $oauthProvider = $this->getProvider();

        // error
        if(\Craft\craft()->request->getParam('error'))
        {
            throw new \Exception("An error occured: ".\Craft\craft()->request->getParam('error'));
        }

        $state = \Craft\craft()->request->getParam('state');
        $code = \Craft\craft()->request->getParam('code');
        $oauth2state = \Craft\craft()->httpSession->get('oauth2state');

        if (is_null($code))
        {
            $authorizationOptions = $options['authorizationOptions'];

            if(count($options['scope']) > 0)
            {
                $authorizationOptions['scope'] = $options['scope'];
            }

            $authorizationUrl = $oauthProvider->getAuthorizationUrl($authorizationOptions);

            $state = $oauthProvider->getState();

            \Craft\craft()->httpSession->add('oauth2state', $state);

            OauthPlugin::log('OAuth 2.0 Connect - Redirect to the authorization URL'."\r\n".
	            "authorizationUrl: ".$authorizationUrl."\r\n".
	            "oauth2state: ".\Craft\craft()->httpSession->get('oauth2state')
	        , LogLevel::Info);

            \Craft\craft()->request->redirect($authorizationUrl);
        }
        elseif (!$state || $state !== $oauth2state)
        {
            OauthPlugin::log('OAuth 2.0 Connect - Invalid State'."\r\n".print_r([
                'state' => $state,
                'oauth2state' => $oauth2state,
            ], true), LogLevel::Info);

            \Craft\craft()->httpSession->remove('oauth2state');

            throw new \Exception("Invalid state");

        }
        else
        {
            OauthPlugin::log('OAuth 2.0 Connect - Authorization code retrieved: '.$code, LogLevel::Info);

            $token = $oauthProvider->getAccessToken('authorization_code', [
                'code' => $code
            ]);

            OauthPlugin::log("OAuth 2.0 Connect - Get Access Token\r\n".
	            "Access token: \r\n".
	            print_r($token, true)
	        , LogLevel::Info);
        }

        return $token;
    }
61038
public function get_auth_user($openid , $access_token , $lang = 'zh_CN'){

        $url = self::API_URI . self::AUTH_USER_URI;
        $param['access_token'] = $access_token;
        $param['openid'] = $openid;
        $param['lang'] = $lang;

        $user_info_url = $this->create_url($url, $param);
        $data = $this->http_get($user_info_url);

        return $this->return_data($data);
    }
647675
function getAccessToken($oauth_verifier = FALSE)
    {
        $parameters = [];
        if (!empty($oauth_verifier)) {
            $parameters['oauth_verifier'] = $oauth_verifier;
        }
        $request = $this->oAuthRequest($this->accessTokenURL(), 'GET', $parameters);
        $token = OAuthUtil::parse_parameters($request);
        $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
        return $token;
    }
417103
public function checkOauth2AccessToken($accessToken, $openId)
    {
        $result = $this->httpGet(self::WECHAT_SNS_AUTH_PREFIX, [
            'access_token' => $accessToken,
            'openid' => $openId
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
134735
public function userinfo($access_token)
    {
        return $this->apiClient->get()
        ->userinfo()
        ->withHeader(new ContentType('application/json'))
        ->withHeader(new AuthorizationBearer($access_token))
        ->call();
    }