Home >php教程 >php手册 >PHP 签名

PHP 签名

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 19:58:391081browse

首先定义一个数组用于存储签名所需的各个参数 , 并用 ksort 方法对其进行键名的升序排序 $array [ 'access_token' ]= $accesstoken ; $array [ 'app_id' ]= $appid ; $array [ 'timestamp' ]=date( 'Y-m-jG:i:s' ); ksort( $array ); 将数组传入 buildPlainT

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


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn