diff --git a/wchat/common/HttpClient.php b/wchat/common/HttpClient.php index a32b210..a7a25a0 100644 --- a/wchat/common/HttpClient.php +++ b/wchat/common/HttpClient.php @@ -681,22 +681,13 @@ class HttpClient curl_setopt($ch, CURLOPT_POST, 1); } - if ($this->method != self::GET && !empty($this->_data)) { - $this->_data = $this->mergeParams($data); - } else { - $this->_data = $this->mergeParams($data); - } curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($this->method)); - - 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); - } + if ($this->method === self::GET && !empty($this->_data)) { + curl_setopt($ch, CURLOPT_POSTFIELDS, $this->toRequest($data)); + } + if ($this->method === self::POST) { + curl_setopt($ch, CURLOPT_POSTFIELDS, $this->mergeParams($data)); } - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_data); $output = curl_exec($ch); if ($output === false) {