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

PHP 签名

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:58:39
Original
1091 people have browsed it

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


Related labels:
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template