PHP 签名

来源:互联网 发布:淘宝店铺自动回复 编辑:程序博客网 时间:2024/05/09 10:46

首先定义一个数组用于存储签名所需的各个参数,并用ksort方法对其进行键名的升序排序

$array['access_token']=$accesstoken;

$array['app_id']=$appid;

$array['timestamp']=date('Y-m-jG:i:s');

ksort($array);


将数组传入buildPlainText方法生成明文

$plaintext= buildPlainText($array);


将明文加密成为接口中所需的入参sign$appsecret为应用密钥

$cipherText= base64_encode(hash_hmac("sha1",$plaintext,$appsecret,$raw_output=True));

$cipherText= urlencode($cipherText);


0 0