//返回当前的毫秒时间戳
function msectime() {
  list($msec, $sec) = explode(' ', microtime());
  $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);

  return $msectime;
}
// 用timestamp+"\n"+AppSecret为签名字符串,AppSecret为签名密钥,使用算法HmacSHA256计算的签名值。
<?php
    // 根据timestamp, appSecret计算签名值
    $s = hash_hmac('sha256', 'timestamp', 'appSecret', true);
    $signature = base64_encode($s);
    var_dump($signature);
    $urlencode_signature = urlencode($signature);
    var_dump($urlencode_signature);
?>

posted on 2023-03-21 17:28  depressiom  阅读(207)  评论(0编辑  收藏  举报