Update WeChat/Script.php

This commit is contained in:
Anyon 2018-11-12 14:37:32 +08:00
parent a2d43b86b0
commit 42a07c153b

View File

@ -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));
}
}