CreateSignature


代码示列

<?php


//非加密请求数据
$post_data = array(
    "appid" => "10000",
    "signature" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "sign_type" => "md5",
    "timestamp" => "1594881294",
    "other" => "content"
);

$temp = $post_data;
unset($temp['signature']);
ksort($temp);
reset($temp);

$tempStr = "";
foreach ($temp as $key => $value) {
    $tempStr.=$key."=".$value."&amp;";
}
$tempStr = substr($tempStr,0,count($tempStr)-2);
if($sign_type == "md5")
    $post_data['signature'] = md5($appid.$appkey.$tempStr.$appid.$appkey);
else
    $post_data['signature'] = sha1($appid.$appkey.$tempStr.$appid.$appkey);

print_r($post_data);