getCurrentUrl() public static method

获取当前 URL
public static getCurrentUrl ( )
Exemplo n.º 1
0
 /**
  * 获取授权 URL
  */
 public function getAuthorizeUrl()
 {
     if (null === $this->state) {
         $this->state = Util::getRandomString(16);
     }
     $this->stateManager->setState($this->state);
     $query = array('appid' => $this->appid, 'redirect_uri' => $this->redirectUri ?: Util::getCurrentUrl(), 'response_type' => 'code', 'scope' => $this->resolveScope(), 'state' => $this->state);
     return $this->resolveAuthorizeUrl() . '?' . http_build_query($query);
 }
Exemplo n.º 2
0
 /**
  * 获取配置
  */
 public function getConfig($asArray = false)
 {
     $options = array('appid' => $this->accessToken->getAppid(), 'url' => Util::getCurrentUrl(), 'timestamp' => Util::getTimestamp(), 'noncestr' => Util::getRandomString(), 'accesstoken' => $this->accessToken['access_token']);
     // 按 ASCII 码排序
     ksort($options);
     $signature = http_build_query($options);
     $signature = urldecode($signature);
     $signature = sha1($signature);
     $config = array('appId' => $options['appid'], 'scope' => 'jsapi_address', 'signType' => 'sha1', 'addrSign' => $signature, 'timeStamp' => $options['timestamp'], 'nonceStr' => $options['noncestr']);
     return $asArray ? $config : Serializer::jsonEncode($config);
 }
Exemplo n.º 3
0
 /**
  * 获取配置文件
  */
 public function getConfig($asArray = false)
 {
     $ticket = new Ticket($this->accessToken);
     if ($this->cache) {
         $ticket->setCache($this->cache);
     }
     $options = array('jsapi_ticket' => $ticket->getTicketString(), 'timestamp' => Util::getTimestamp(), 'url' => Util::getCurrentUrl(), 'noncestr' => Util::getRandomString());
     ksort($options);
     $signature = sha1(urldecode(http_build_query($options)));
     $configure = array('appId' => $this->accessToken['appid'], 'nonceStr' => $options['noncestr'], 'timestamp' => $options['timestamp'], 'signature' => $signature, 'jsApiList' => $this->api, 'debug' => (bool) $this->debug);
     return $asArray ? $configure : Serializer::jsonEncode($configure);
 }