From 2fd61071fa14dd355827b02a47bd5171bb0ae9eb Mon Sep 17 00:00:00 2001 From: giantwu Date: Tue, 3 Sep 2019 12:42:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AD=BE=E5=90=8D=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E9=BB=98=E8=AE=A4=E6=8B=BC=E6=8E=A5xml?= =?UTF-8?q?=E6=97=B6=20=E4=BD=BF=E7=94=A8cdata=E3=80=82=E7=94=A8=E6=9D=A5?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6=E5=AF=B9?= =?UTF-8?q?xml=E7=9A=84=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WeChat/Utility.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/WeChat/Utility.php b/src/WeChat/Utility.php index 6aa2a1e..e3886c5 100644 --- a/src/WeChat/Utility.php +++ b/src/WeChat/Utility.php @@ -51,11 +51,14 @@ public function generateSign(array $data): string */ private function getSignContent(array $data): string { + return urldecode(http_build_query($data)); + /* $buff = ''; foreach ($data as $k => $v) { $buff .= ($k != 'sign' && $v != '' && !is_array($v)) ? $k . '=' . $v . '&' : ''; } return trim($buff, '&'); + */ } /** @@ -94,7 +97,7 @@ public function request(string $endpoint, Base $bean, bool $useCert = false): st $bean->setAppId($this->config->getAppId()); $bean->setMchId($this->config->getMchId()); $bean->setSign($this->generateSign($bean->toArray())); - $response = NewWork::postXML($this->config->getGateWay() . $endpoint, (new SplArray($bean->toArray()))->toXML(), $useCert ? [ + $response = NewWork::postXML($this->config->getGateWay() . $endpoint, (new SplArray($bean->toArray()))->toXML(true), $useCert ? [ 'ssl_cert_file' => $this->config->getApiClientCert(), 'ssl_key_file' => $this->config->getApiClientKey()] : []);