签名示例

最近更新时间:2019-05-24 18:08:52

本签名示例代码仅供参考,请根据实际情况使用。

PHP 示例代码

<?php
$secretKey = 'xxxxx';
$srcStr = 'POSTdsa.api.qcloud.com/v2/index.php?';
$param = [ 
    "Action"=>"UpdateDsaHostInfo",
    "Nonce"=>rand(),
    "SecretId"=>"xxxxx",
    "Timestamp"=> time(),
    "https"=>json_encode(["type"=>4]),
    "hostId"=>4848,
    ];  
ksort($param); //参数排序
$srcStr .= urldecode(http_build_query($param));
echo $srcStr.PHP_EOL;

$signStr = base64_encode(hash_hmac('sha1', $srcStr, $secretKey, true));
echo $signStr;