From 8e1d54413a7a4e090f0227030ee6f683374fa061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 25 Nov 2020 16:47:43 +0800 Subject: [PATCH] add clear --- wchat/common/HttpClient.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wchat/common/HttpClient.php b/wchat/common/HttpClient.php index 213652b..9271756 100644 --- a/wchat/common/HttpClient.php +++ b/wchat/common/HttpClient.php @@ -681,6 +681,14 @@ class HttpClient curl_setopt($ch, CURLOPT_POST, 1); } if ($this->method == self::GET || !empty($this->_data)) { + if (!is_string($this->_data)) { + $message = $this->header['Content-Type'] ?? $this->header['content-type'] ?? 'application/json'; + if ($message == 'application/json') { + $this->_data = json_encode($this->_data, JSON_UNESCAPED_UNICODE); + } else { + $this->_data = http_build_query($this->_data); + } + } curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_data); } else { curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mergeParams($data));