/** * 获取配置 */ 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); }
/** * 获取配置文件 */ 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); }
/** * 获取配置 */ public function getConfig($asArray = false) { $config = $this->resolveConfig(); return $asArray ? $config : Serializer::jsonEncode($config); }
/** * Request Json Body */ public function withBody(array $body) { $this->body = Serializer::jsonEncode($body); return $this; }