php api接口数字签名,验签

<?php

//说明:第三方请求参数中,需要在平台申请帐号,生成一个appid,每个appid对应一个appserect,请求如下:

$param = array(
  'appid'=>'137876891',
  'name'=>'张三',
  'mobile'=>'1389***9108',
  'age'=>'29',
  'content'=>'这是一封测试邮件',
);

//对于数组进行升序排序

asort($param);

//每个参数用&连接起来

$str = http_build_query($array);

//在字符串$str最后拼接appserect

$res = $str.$appserect;

//sha1 之后再转化为大写

$sign = strtoupper(sha1($res));

$param['sign'] = $sign;

//服务器端和上述匹配规则一致,如下图:

猜你喜欢

转载自www.cnblogs.com/ayanboke/p/10082607.html