/** * 生成outh URL * * @param string $to * @param string $scope * @param string $state * * @return string */ 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); return self::API_URL . '?' . http_build_query($params) . '#wechat_redirect'; }
/** * 获取当前URL. * * @return string */ public function getUrl() { if ($this->url) { return $this->url; } return Url::weixin(); }