@@ -170,12 +170,8 @@ private function request($method, $path, array $params = [], $arrays = null)
170170 $ params .= '& ' .$ key .'= ' .$ encoded_value ;
171171 }
172172 }
173- #echo $url;
174- #echo "\n";
175- //echo $params."\n\n";
176173 $ curl = curl_init ($ url );
177174
178- curl_setopt ($ curl , CURLOPT_USERPWD , $ this ->key );
179175 curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , $ method );
180176 curl_setopt ($ curl , CURLOPT_RETURNTRANSFER , true );
181177 curl_setopt ($ curl , CURLOPT_FOLLOWLOCATION , true );
@@ -186,13 +182,13 @@ private function request($method, $path, array $params = [], $arrays = null)
186182 curl_setopt ($ curl , CURLOPT_TIMEOUT , $ this ->curlTimeout );
187183
188184 curl_setopt ($ curl , CURLOPT_USERAGENT , self ::USER_AGENT );
189- curl_setopt ($ curl , CURLOPT_HTTPHEADER , array ('Content-Type: application/x-www-form-urlencoded ' ));
190-
191- curl_setopt ($ curl , CURLOPT_POSTFIELDS , $ params );
192-
185+
186+ if ($ method == 'POST ' ) {
187+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , $ params );
188+ curl_setopt ($ curl , CURLOPT_HTTPHEADER , array ('Content-Type: application/x-www-form-urlencoded ' ));
189+ }
193190
194191 $ this ->lastResponseRaw = curl_exec ($ curl );
195-
196192 $ errorNumber = curl_errno ($ curl );
197193 $ error = curl_error ($ curl );
198194 curl_close ($ curl );
@@ -201,10 +197,7 @@ private function request($method, $path, array $params = [], $arrays = null)
201197 throw new QencodeException ('CURL: ' . $ error , $ errorNumber );
202198 }
203199
204- #echo $this->lastResponseRaw;
205- #echo "\n\n";
206200 $ this ->lastResponse = $ response = json_decode ($ this ->lastResponseRaw , true );
207- //print_r($response);
208201
209202 if ($ method == 'GET ' )
210203 return $ response ;
@@ -214,12 +207,6 @@ private function request($method, $path, array $params = [], $arrays = null)
214207 $ e ->rawResponse = $ this ->lastResponseRaw ;
215208 throw $ e ;
216209 }
217- /*$status = (int)$response['code'];
218- if ($status < 200 || $status >= 300) {
219- $e = new QencodeApiException((string)$response['result'], $status);
220- $e->rawResponse = $this->lastResponseRaw;
221- throw $e;
222- }*/
223210 if ($ response ['error ' ] != 0 ) {
224211 $ e = new QencodeApiException ($ response ['message ' ]);
225212 $ e ->rawResponse = $ this ->lastResponseRaw ;
0 commit comments