$host, 'date' => $date, 'authorization' => $authrization ]); return $uri; } /** * 根据所提供信息返回签名 * * @param string $appId appid * @param string $secretKey secretKey * @param string $timestamp 时间戳,不传的话使用系统时间 * @return string */ public static function signV1($appId, $secretKey, $timestamp = null) { $timestamp = $timestamp ?: time(); $baseString = $appId . $timestamp; $signa_origin = hash_hmac('sha1', md5($baseString), $secretKey, true); return base64_encode($signa_origin); } /** * https调用的鉴权参数构造 * * @param string $appId appId * @param string $apiKey apiKey * @param string $curTime curTime * @param string $param param * @return array */ public static function signV2($appId, $apiKey, $param, $curTime = null) { if (empty($curTime)) { $curTime = time(); } return [ 'X-Appid' => $appId, 'X-CurTime' => $curTime, 'X-Param' => base64_encode($param), 'X-CheckSum' => md5($apiKey . $curTime . base64_encode($param)) ]; } }