/** * 微信OAuth2授权 * * @param string $redirect_uri * @param string $state 可选值:'base' or 'detail' */ public function authorizing($redirect_uri, $state = 'base') { if (!in_array($state, array('base', 'detail'))) { $state = 'base'; } $scope = 'detail' == $state ? 'snsapi_userinfo' : 'snsapi_base'; $url = $this->oauth->setConfig(array('redirect_uri' => $redirect_uri, 'scope' => $scope, 'state' => $state))->authorize_url(); Response::redirect($url); }