正在显示
1 个修改的文件
包含
12 行增加
和
3 行删除
| @@ -80,14 +80,23 @@ class Api | @@ -80,14 +80,23 @@ class Api | ||
| 80 | { | 80 | { |
| 81 | $recv_window = '5000'; | 81 | $recv_window = '5000'; |
| 82 | $queryString = ''; | 82 | $queryString = ''; |
| 83 | + $postBody = ''; | ||
| 83 | 84 | ||
| 84 | if ($method == 'GET' && !empty($params)) { | 85 | if ($method == 'GET' && !empty($params)) { |
| 86 | + ksort($params); | ||
| 85 | $queryString = http_build_query($params); | 87 | $queryString = http_build_query($params); |
| 86 | } | 88 | } |
| 87 | - | ||
| 88 | - $sign_str = $timestamp . $this->apiInfo->key . $recv_window . $path . $queryString; | ||
| 89 | if ($method == 'POST' && !empty($params)) { | 89 | if ($method == 'POST' && !empty($params)) { |
| 90 | - $sign_str .= json_encode($params); | 90 | + ksort($params); |
| 91 | + $postBody = json_encode($params); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + $sign_str = $timestamp . $this->apiInfo->key . $recv_window . $path; | ||
| 95 | + if ($queryString) { | ||
| 96 | + $sign_str .= '?' . $queryString; | ||
| 97 | + } | ||
| 98 | + if ($postBody) { | ||
| 99 | + $sign_str .= $postBody; | ||
| 91 | } | 100 | } |
| 92 | 101 | ||
| 93 | return hash_hmac('sha256', $sign_str, $this->apiInfo->secret); | 102 | return hash_hmac('sha256', $sign_str, $this->apiInfo->secret); |
-
请 注册 或 登录 后发表评论