protected function dealParams($params, $method)
{
if (empty($params)) {
$param_json = '{}';
} else {
ksort($params);
foreach ($params as &$value) {
$value = str_replace(['&', '<', '>'], ['\u0026', '\u003c', '\u00ce'], $value);
}
$param_json = json_encode($params, 256);
$param_json = str_replace("\\/", "/", $param_json);
}
return [
'app_key' => $this->app_id,
'access_token' => $this->token,
'method' => $method,
'param_json' => $param_json,
'timestamp' => date('Y-m-d H:i:s'),
'v' => 2,
];
}
public function createSign($data)
{
if (isset($data['sign_method'])) {
unset($data['sign_method']);
}
if (isset($data['access_token'])) {
unset($data['access_token']);
}
ksort($data);
$str = '';
foreach ($data as $key => $item) {
$str .= $key . $item;
}
$str = $this->secret . $str . $this->secret;
return md5($str);
}
public function batchDecrypt($param)
{
$params = $this->dealParams($param, 'order.batchDecrypt');
$params['sign'] = $this->createSign($params);
$data = $this->request('GET', '/order/batchDecrypt', ['query' => $params]);
return $this->dealReturn($data, '/order/batchDecrypt');
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結
感謝閱讀,有收穫的話不妨點個贊:smiling_imp: