首先定义一个数组用于存储签名所需的各个参数,并用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);