使用微信登陆
@param string $url
@param string $state
@return string
968528
public function getLoginUrl($url, $state)
    {
        return sprintf(self::LOGIN_QR_CODE_URL, $this->appId, urlencode($url), trim($state));
    }
1283924
protected function getQrConnectUrl($state)
    {
        $queries = [
            'appid' => $this->clientId,
            'agentid' => $this->agentId,
            'redirect_uri' => $this->redirectUrl,
            'state' => $state,
        ];

        return 'https://open.work.weixin.qq.com/wwopen/sso/qrConnect?'.http_build_query($queries);
    }
719426
public function createStatus(string $sha, string $state, string $targetUrl = null, string $description = null,
                                 string $context = 'default'): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/statuses/:sha',
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $sha), Request::METHOD_POST, [
                'state'       => $state,
                'target_url'  => $targetUrl,
                'description' => $description,
                'context'     => $context
            ]);
    }
947181
protected function getMessage(string $url): ?string
    {
        $response = wp_remote_get($url);
        $responseCode = wp_remote_retrieve_response_code($response);

        if (! is_int($responseCode)) {
            return 'Unable to reach ' . $url;
        }

        return ($this->expectedStatusCode === $responseCode)
            ? null
            : $url . ' returns ' . $responseCode;
    }
1038823
protected function getState($state = null)
	{
		if(null === $state)
		{
			if(null === $this->state)
			{
				$this->state = md5(\uniqid('', true));
			}
		}
		else
		{
			$this->state = $state;
		}
		return $this->state;
	}
854279
public function getOAuthRedirectUrl(string $redirectUri = '', string $scope = 'snsapi_userinfo', string $state = null)
    {
        $redirectUri || $redirectUri = $this->app->config['redirect_uri_oauth'];
        $state || $state = rand();
        $params = [
            'appid' => $this->app['config']['suite_id'],
            'redirect_uri' => $redirectUri,
            'response_type' => 'code',
            'scope' => $scope,
            'state' => $state,
        ];

        return 'https://open.weixin.qq.com/connect/oauth2/authorize?'.http_build_query($params).'#wechat_redirect';
    }
904593
function renderingTitle($state = null) {
		if (!is_null($state)) {
			$this->_renderingTitle = $state;
		}
		return $this->_renderingTitle;
	}
777942
public function url($to = null, $scope = 'snsapi_userinfo', $state = 'STATE')
    {
        $to !== null || $to = Url::current();

        $params = array(
            'appid'           => $this->appId,
            'redirect_uri'    => $to,
            'response_type'   => 'code',
            'scope'           => $scope,
            'state'           => $state,
            'component_appid' => $this->component_appid,
        );

        return self::API_URL . '?' . http_build_query($params) . '#wechat_redirect';
    }
799078
public function authenticate($url = null, $stateOptions = [])
    {
        $loginURL = $url === null ? $this->credentials['loginURL'] : $url;

        $stateOptions['loginUrl'] = $loginURL;
        $state = '&state='.urlencode(json_encode($stateOptions));
        $parameters = $this->settings['parameters'];

        $loginURL .= '/services/oauth2/authorize';
        $loginURL .= '?response_type=code';
        $loginURL .= '&client_id='.$this->credentials['consumerKey'];
        $loginURL .= '&redirect_uri='.urlencode($this->credentials['callbackURI']);
        $loginURL .= !empty($parameters['display']) ? '&display='.$parameters['display'] : '';
        $loginURL .= $parameters['immediate'] ? '&immediate=true' : '';
        $loginURL .= !empty($parameters['scope']) ? '&scope='.rawurlencode($parameters['scope']) : '';
        $loginURL .= !empty($parameters['prompt']) ? '&prompt='.rawurlencode($parameters['prompt']) : '';
        $loginURL .= $state;

        return $this->redirect->to($loginURL);
    }
12248
public static function getProtocol($url)
    {
        $urlInfo = static::info($url);

        return ArrayHelper::get($urlInfo, 'protocol', null, true);
    }
286853
public static function getUrlWithProtocol($url) {
		if(empty($url)) {
			return $url;
		}
		list($scheme, $host) = self::splitUrl($url);
		if(empty($scheme) || empty($host)) {
			return '';
		}
		return $scheme.'://'.$host;
	}
299159
protected function getOAuthUrl($state)
    {
        $queries = [
            'appid' => $this->clientId,
            'redirect_uri' => $this->redirectUrl,
            'response_type' => 'code',
            'scope' => $this->formatScopes($this->scopes, $this->scopeSeparator),
            'agentid' => $this->agentId,
            'state' => $state,
        ];

        return sprintf('https://open.weixin.qq.com/connect/oauth2/authorize?%s#wechat_redirect', http_build_query($queries));
    }
585527
protected function setState($state)
    {
        $serviceService = $this->getServiceLocator()->get(StateStorage::SERVICE_ID);
        $userUri = $this->getSession()->getUserUri();
        return is_null($userUri) ? false : $serviceService->set($userUri, $this->getServiceCallId(), $state);
    }
655254
public function recode_legacy_state_answer($state) {
        $answer = $state->answer;
        $result = '';
        if ($answer) {
            $result = $this->get_mappingid('question_answer', $answer);
        }
        return $result;
    }
346402
public function isLanguageIncludedInRoutes($state = null)
    {
        if (isset($state)) {
            $this->languageIncludedInRoutes = (bool) $state;
        }

        return $this->languageIncludedInRoutes;
    }
259469
public function describeMachineState($state, $field = null)
	{
		if ($field === null) {
			return @ $this->states[$state];
		} else {
			return @ $this->states[$state][$field];
		}
	}
1244685
private function getElement( string $buffer, string $state )
    {
        $is_keyword = isset($this->_keywords[$buffer]) ? TRUE : FALSE;
        $type = $is_keyword ? PhpSourceElement::TYPE_KEYWORD : PhpSourceElement::TYPE_IDENTIFIER;
        return new PhpSourceElement( $buffer, $type, $state );
    }