/** * 签名 * * @param string $url * @param string $nonce * @param int $timestamp * * @return array */ public function getSignaturePackage($url = null, $nonce = null, $timestamp = null) { $url = $url ? $url : \Tool_Url::current(); $nonce = $nonce ? $nonce : md5($_SERVER['REQUEST_TIME']); $timestamp = $timestamp ? $timestamp : $_SERVER['REQUEST_TIME']; $ticket = $this->getTicket(); $sign = array('appId' => $this->app_id, 'nonceStr' => $nonce, 'timestamp' => $timestamp, 'signature' => $this->getSignature($ticket, $nonce, $timestamp, $url)); //$sign['t']=$ticket; return $sign; }
/** * 前往api服务器进行授权 * * @param null $plat */ public function toapi($plat = null) { if ($plat === null) { $param = 'id=' . $this->app_id; } elseif (is_numeric($plat)) { $param = 'plat=' . $plat; } else { $param = 'id=' . $this->{$plat}; } $url = \Tool_Url::current(); $url .= (strpos($url, '?') ? '&' : '?') . 'wxauthnoredirect=1'; header('Location:' . self::API_DUDU_AUTH . '?' . $param . '&url=' . rawurlencode(base64_encode($url))); exit; }
/** * 拼接URL,支持Controller名称传入或者直接URI传入 * $type 类型=default默认情况下,user=用户,=broker经纪人,=developer开发商 * @param string $type 如果是cms内部网站,这个参数一般不用传,直接读取入口文件的BASE_URI_PRI * @param $controllerName Controller名称 * @param array $params 参数数组 * @param bool $toLower 是否将URL转成小写 * @param string $type * @return string */ public function build_url($controllerName, $params = array(), $toLower = true, $type = "") { return Tool_Url::build_query_url($controllerName, $params, $toLower, $type); }