From 42a07c153b01e624be885af831a5b170ce24bf10 Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 12 Nov 2018 14:37:32 +0800 Subject: [PATCH] Update WeChat/Script.php --- WeChat/Script.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/WeChat/Script.php b/WeChat/Script.php index a8a664d..59099d2 100644 --- a/WeChat/Script.php +++ b/WeChat/Script.php @@ -14,8 +14,8 @@ namespace WeChat; -use WeChat\Contracts\Tools; use WeChat\Contracts\BasicWeChat; +use WeChat\Contracts\Tools; use WeChat\Exceptions\InvalidResponseException; /** @@ -104,18 +104,14 @@ class Script extends BasicWeChat * 数据生成签名 * @param array $data 签名数组 * @param string $method 签名方法 + * @param array $params 签名参数 * @return bool|string 签名值 */ - protected function getSignature($data, $method = "sha1") + protected function getSignature($data, $method = "sha1", $params = []) { - if (!function_exists($method)) { - return false; - } ksort($data); - $params = []; - foreach ($data as $key => $value) { - $params[] = "{$key}={$value}"; - } + if (!function_exists($method)) return false; + foreach ($data as $k => $v) array_push($params, "{$k}={$v}"); return $method(join('&', $params)); } } \ No newline at end of file