获取粉丝数据(当前公众号唯一)
@param bool $oauth 是否通过微信服务器Oauth API跳转获取 通过API获取的用户信息会存入session中
@return mixed
336550
public function getFans($oauth = true)
    {
        if ($this->_fans === null) {
            $wechat = $this->getWechat();
            $sessionKey = self::SESSION_MOBILE_FANS_PREFIX . '_' . $wechat->id;
            $openId = Yii::$app->session->get($sessionKey);
            if (!$openId && $oauth) { // API获取用户
                $data = $wechat->getSdk()->getAuthorizeUserInfo('fansInfo');
                if (isset($data['openid'])) {
                    $openId = $data['openid'];
                }
            }
            if (!$openId || ($fans = Fans::findByOpenId($openId)) === null) {
                return false;
            }
            $this->setFans($fans);
        }
        return $this->_fans;
    }
1343486
protected function getToken()
    {
        if (!$this->isStateless()) {
            $temp = $this->request->getSession()->get('oauth.temp');

            return $this->server->getTokenCredentials(
                $temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
            );
        }
        $temp = unserialize($this->request->session()->get('oauth_temp'));

        return $this->server->getTokenCredentials(
                $temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
            );
    }
403604
public function oauth_callback() {
		if (!session_id()) {
			session_start();
		}
		$session = $_SESSION['_opauth_twitter'];
		unset($_SESSION['_opauth_twitter']);

		if (!empty($_REQUEST['oauth_token']) && $_REQUEST['oauth_token'] == $session['oauth_token']) {
			$this->tmhOAuth->config['user_token'] = $session['oauth_token'];
			$this->tmhOAuth->config['user_secret'] = $session['oauth_token_secret'];
			
			$params = array(
				'oauth_verifier' => $_REQUEST['oauth_verifier']
			);
		
			$results =  $this->_request('POST', $this->strategy['access_token_url'], $params);

			if ($results !== false && !empty($results['oauth_token']) && !empty($results['oauth_token_secret'])) {
				$credentials = $this->_verify_credentials($results['oauth_token'], $results['oauth_token_secret']);
				
				if (!empty($credentials['id'])) {
					
					$this->auth = array(
						'uid' => $credentials['id'],
						'info' => array(
							'name' => $credentials['name'],
							'nickname' => $credentials['screen_name'],
							'urls' => array(
								'twitter' => str_replace('{screen_name}', $credentials['screen_name'], $this->strategy['twitter_profile_url'])
							)
						),
						'credentials' => array(
							'token' => $results['oauth_token'],
							'secret' => $results['oauth_token_secret']
						),
						'raw' => $credentials
					);
					
					$this->mapProfile($credentials, 'location', 'info.location');
					$this->mapProfile($credentials, 'description', 'info.description');
					$this->mapProfile($credentials, 'profile_image_url_https', 'info.image');
					$this->mapProfile($credentials, 'url', 'info.urls.website');
					$this->mapProfile($credentials, 'email', 'info.email');
					
					$this->callback();
				}
			}
		} else {
			$error = array(
				'code' => 'access_denied',
				'message' => 'User denied access.',
				'raw' => $_GET
			);

			$this->errorCallback($error);
		}
		
				
	}
333553
function oAuthRequest($url, $method, $parameters, $multi = false) {

    if (strrpos($url, 'http://') !== 0 && strrpos($url, 'https://') !== 0) {
      $url = "{$this->host}{$url}.{$this->format}";
  }

  switch ($method) {
    case 'GET':
      $url = $url . '?' . http_build_query($parameters);
      return $this->http($url, 'GET');
    default:
      $headers = array();
      if (!$multi && (is_array($parameters) || is_object($parameters)) ) {
        $body = http_build_query($parameters);
      } else {
        $body = self::build_http_query_multi($parameters);
        $headers[] = "Content-Type: multipart/form-data; boundary=" . self::$boundary;
      }
      return $this->http($url, $method, $body, $headers);
  }
  }
1026916
public function getRequestToken($callback = 'oob')
    {
        $request = $this->createRequest('/oauth/request_token', OAuthResponse::FORMAT_STR);
        $request->setOAuthParameter('oauth_callback', $callback);
        $this->signRequest($request, new OAuthToken());

        return $this->createOAuthToken($this->sendRequest($request));
    }
342971
function refreshToken($accessToken, $sessionHandle) {
		$code = $this->request ( 'GET', $this->url ( 'AccessToken', '' ), array (
				'oauth_token' => $accessToken,
				'oauth_session_handle' => $sessionHandle 
		) );
		if ($this->response ['code'] == 200) {
			
			$response = $this->extract_params ( $this->response ['response'] );
			
			return $response;
		} else {
			$this->response ['helper'] = "TokenFatal";
			return $this->response;
		}
	}
272286
private function buildAuthorizationHeader($oauth) 
    {
        $return = 'Authorization: OAuth ';
        $values = array();
        
        foreach($oauth as $key => $value)
        {
            $values[] = "$key=\"" . rawurlencode($value) . "\"";
        }
        
        $return .= implode(', ', $values);
        return $return;
    }
284052
public function oauthSpec($provider)
	{
		$service = $this->service($provider);
		
		if (false !== stristr(get_class($service), 'OAuth1')) {
			return 1;
		}
		else if (false !== stristr(get_class($service), 'OAuth2')) {
			return 2;
		}
		
		return null;
	}
1189181
public function getOauthAuth($access_token,$openid){
        $result = $this->http_get(self::API_BASE_URL_PREFIX.self::OAUTH_AUTH_URL.'access_token='.$access_token.'&openid='.$openid);
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            } else
              if ($json['errcode']==0) return true;
        }
        return false;
    }
1039847
public function getOAUTHInstance()
    {
        if (!is_object($this->oauth)) {
            $this->oauth = new PHPMailerOAuthGoogle(
                $this->oauthUserEmail,
                $this->oauthClientSecret,
                $this->oauthClientId,
                $this->oauthRefreshToken
            );
        }
        return $this->oauth;
    }
974358
protected function getAuthUrl($state)
    {
        // 网页授权登录
        if (!empty($this->scopes)) {
            return $this->getOAuthUrl($state);
        }

        // 第三方网页应用登录（扫码登录）
        return $this->getQrConnectUrl($state);
    }
1033864
function getAccessToken($args = array()) {/*{{{*/
    $r = $this->oAuthRequest($this->accessTokenURL(), $args);
    //var_dump($r);
    $token = $this->oAuthParseResponse($r);
    $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
    return $token;
  }
732094
public function refreshAccessToken(OAuthToken $token)
    {
        $params = [
            'grant_type' => 'refresh_token'
        ];
        $params = array_merge($token->getParams(), $params);

        $request = $this->createRequest()
            ->setMethod('POST')
            ->setUrl($this->refreshTokenUrl)
            ->setData($params);

        $this->applyClientCredentialsToRequest($request);

        $response = $this->sendRequest($request);

        $token = $this->createToken(['params' => $response]);
        $this->setAccessToken($token);

        return $token;
    }
1300678
protected function getOAuthCode()
    {
        // 1. 如果请求不带code,不再处理
        if (!isset($this->request['code']) || !isset($this->request['state'])) {
            return false;
        }

        // 2. 检查是否为认证服务号
        $account = wei()->wechatAccount->getCurrentAccount();
        if (!$account->isVerifiedService()) {
            $this->logger->info('Got OAuth code, but wechat account is not verified service');

            return false;
        }

        // 3. 如果code已经处理过,不再处理
        if (!wei()->cache->add('wechatOAuth2Code' . $this->request['code'], true, 86400 * 3)) {
            return false;
        }

        return $this->request['code'];
    }
695990
public function loginOAuthUser(OAuthUserContract $user)
    {
        /** @noinspection PhpUndefinedFieldInspection */
        $responseBody = $user->accessTokenResponseBody;
        /** @noinspection PhpUndefinedFieldInspection */
        $token = $user->token;

        $dfUser = $this->createShadowOAuthUser($user);
        $dfUser->last_login_date = Carbon::now()->toDateTimeString();
        $dfUser->confirm_code = null;
        $dfUser->save();

        $map = OAuthTokenMap::whereServiceId($this->id)->whereUserId($dfUser->id)->first();
        if (empty($map)) {
            OAuthTokenMap::create(
                [
                    'user_id'    => $dfUser->id,
                    'service_id' => $this->id,
                    'token'      => $token,
                    'response'   => $responseBody
                ]);
        } else {
            $map->update(['token' => $token, 'response' => $responseBody]);
        }
        Session::setUserInfoWithJWT($dfUser);
        $response = Session::getPublicInfo();
        $response['oauth_token'] = $token;
        if (isset($responseBody['id_token'])) {
            $response['id_token'] = $responseBody['id_token'];
        }

        return $response;
    }
543788
public static function get_by_oauth_token($oauth_token) {
	$mysql = bootstrap::get_library('mysql');
	
	$sql   = "SELECT * FROM `login_github` WHERE `oauth_token` = '%s';";
	$login = $mysql::select('row', $sql, $oauth_token);
	if (empty($login)) {
		return false;
	}
	
	return new static($login['id']);
}
1168347
public function getOauthAuth($access_token, $openid)
    {
        $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_AUTH_URL . "access_token={$access_token}&openid={$openid}");
        if ($result) {
            $json = json_decode($result, true);
            if (empty($json) || !empty($json['errcode'])) {
                $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
                $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容！';
                Tools::log("WechatOauth::getOauthAuth Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
                return false;
            } elseif (intval($json['errcode']) === 0) {
                return true;
            }
        }
        return false;
    }