更新签名规则

This commit is contained in:
ykxiao 2023-09-08 14:59:32 +08:00
parent 2f30a6cf6f
commit 8c9680d364
1 changed files with 6 additions and 2 deletions

View File

@ -1,9 +1,11 @@
# 德木自动化项目开放接口SDK
# 介绍
用于德木自动化对外开放接口数据交互
# 要求
- php版本>=7.0
# 安装
@ -30,6 +32,7 @@ $response = $w->createProductOrder([
```
# 回调说明
- 配置回调后地址后应用服务器会以POST方式请求你的服务器地址以便你做进一步业务流程。
- 回调你服务器地址后,可获取参数"data"、"signature"进行验签,"response" 为服务器处理结果。
@ -42,7 +45,8 @@ $request = require();
$params = json_decode($request->contents(), true);
// 回调验签
$receivedSignature = $request->headers('signature');
$receivedSignature = $request->headers('mes-open-signature');
$timestamp = $request->headers('mes-open-timestamp');
$data = json_encode($params['data']);
/**
* 生成HMAC签名
@ -55,7 +59,7 @@ function generateHmacSignature($data): string
return hash_hmac('sha256', $data, $secretKey);
}
$calculatedSignature = $this->generateHmacSignature($data);
$calculatedSignature = $this->generateHmacSignature($timestamp . $data);
// 验证签名是否匹配 hash_equals($receivedSignature, $calculatedSignature)
if ($receivedSignature === $calculatedSignature) {