公众号网页授权获取用户信息
@param string $scope
@return array|bool
13609
public function getOpenId($scope = 'snsapi_base'){
        if(isset($_GET['code'])){
            $code = $_GET['code'];
            $url = $this->apiUrl."/sns/oauth2/access_token?appid=".self::$config['appId']."&secret=".self::$config['appSecret']."&code={$code}&grant_type=authorization_code";
            $data = $this->curl($url);
            return $this->get($data);
        }else{
            $back_url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'].'?'.$_SERVER['QUERY_STRING'];
            $redirect_uri = urlencode($back_url);
            $code_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".self::$config['appId']."&redirect_uri=".$redirect_uri."&response_type=code&scope=".$scope."&state=STATE&connect_redirect=1#wechat_redirect";
            header("Location: $code_url");
            exit;
        }
    }
416686
public static function getGlobalScope($scope)
    {
        return array_first(static::$globalScopes[get_called_class()], function($key, $value) use ($scope)
        {
            return $scope instanceof $value;
        });
    }
474499
public function addScope($scope)
    {
        $this->validateScopeValue($scope);

        if (false !== $this->getScopeKey($scope)) {
            return $this;
        }

        $this->descriptor['scopes'][] = $scope;
        return $this;
    }
279434
public function hasScope(Scope $scope)
    {
        foreach ($scope->toArray() as $scopeToken) {
            if (!$this->hasScopeToken($scopeToken)) {
                return false;
            }
        }

        return true;
    }
613882
public static function findByPath(string $path, array $scope)
    {
        if (mb_strpos($path, ':')) {
            foreach (explode(':', $path) as $i => $key) {
                if (!isset($scope[$key])) {
                    return null;
                }
                $scope = $scope[$key];
            }
            return $scope;
        }
        return $scope[$path] ?? null;
    }
530594
public function newQueryWithoutScope($scope)
    {
        $this->getGlobalScope($scope)->remove($query = $this->getQuery(), $this);

        return $query;
    }
708050
public function confirmAction(Request $request)
    {
        $confirmCallback = $request->get('confirm_callback');
        if ($confirmCallback === '') {
            $confirmCallback = null;
        }

        return [
            'title'                => $request->get('title'),
            'body'                 => $request->get('body'),
            'id'                   => $request->get('id').rand(1, 100).'-modal',
            'cancel_button_class'  => $request->get('cancel_button_class', 'btn-cancel'),
            'confirm_button_class' => $request->get('confirm_button_class', 'btn-primary'),
            'cancel_button_value'  => $request->get('cancel_button_value'),
            'confirm_button_value' => $request->get('confirm_button_value'),
            'modal_class'          => $request->get('modal_class'),
            'type'                 => $request->get('type'),
            'confirmCallback'      => $confirmCallback,
        ];
    }
879246
public function find($scope)
    {
        if (strpos($scope, '.') === false) {
            $scope = $scope.'.'.AnInflector::singularize($scope);
        }

        if (isset($this[$scope])) {
            return $this[$scope];
        }

        return;
    }
319586
public function scope($scope)
	{
		$scope = (new Scope())->scope($scope);

		$this->scopes[] = $scope;
		return $scope;
	}
664240
public static function getSetting($scope, $key)
    {
        if (!count(self::$settings)) {
            self::load();
        }

        if (isset(self::$settings[$scope][$key])) {
            return self::$settings[$scope][$key];
        }

        return null;
    }
474156
public function scope($scope, ...$args)
    {
        // 查询范围的第一个参数始终是当前查询对象
        array_unshift($args, $this);

        if ($scope instanceof \Closure) {
            call_user_func_array($scope, $args);
            return $this;
        }

        if (is_string($scope)) {
            $scope = explode(',', $scope);
        }

        if ($this->model) {
            // 检查模型类的查询范围方法
            foreach ($scope as $name) {
                $method = 'scope' . trim($name);

                if (method_exists($this->model, $method)) {
                    call_user_func_array([$this->model, $method], $args);
                }
            }
        }

        return $this;
    }
624954
public function scopeExists($scope)
    {
        $scope = explode(' ', $scope);
        $scope_query = array();
        $count = 0;
        foreach ($scope as $key => $val) {
            $result = $this->client->query(array(
                'TableName'     => $this->config['scope_table'],
                'Select'        => 'COUNT',
                'KeyConditions' => array(
                    'scope' => array(
                        'AttributeValueList' => array(array('S' => $val)),
                        'ComparisonOperator' => 'EQ'
                    )
                )
            ));
            $count += $result['Count'];
        }

        return $count == count($scope);
    }
284476
public function isValidScope($scope)
    {
        $reflectionClass = new \ReflectionClass(get_class($this));

        return in_array($scope, $reflectionClass->getConstants(), true);
    }
116591
public function getScope($scope, $key, $default = null)
    {
        return isset($this->data[$scope][$key]) ? $this->data[$scope][$key] : $default;
    }
1082569
public function hasScope($scope)
    {
        if (is_array($scope)) {
            foreach ($scope as $s) {
                if ($this->hasScope($s) === false) {
                    return false;
                }
            }

            return true;
        }

        return $this->getAccessToken()->hasScope($scope);
    }
368588
public function push($scope)
    {
        if (! is_array($scope)) {
            $scope = func_get_args();
        }

        $this->scopes[] = $scope;

        return $this;
    }
291927
public function getDescriptionForScope($scope)
    {
        // Get Scope
        $scopeObject = $this->sm->findScopeByScope($scope);

        if (!$scopeObject) {
            return $scope;
        }

        return $scopeObject->getDescription();
    }