| @@ 42-61 (lines=20) @@ | ||
| 39 | ||
| 40 | $headers = array_merge($headers,static::$headers); |
|
| 41 | ||
| 42 | if($http_method == 'GET'){ |
|
| 43 | if($data && is_array($data)){ |
|
| 44 | $tmp = []; |
|
| 45 | $queried_url = $url; |
|
| 46 | foreach($data as $key=>$val) $tmp[] = $key.'='.$val; |
|
| 47 | $queried_url .= (strpos($queried_url,'?') === false) ? '?' : '&'; |
|
| 48 | $queried_url .= implode('&',$tmp); |
|
| 49 | $opt[CURLOPT_URL] = $queried_url; |
|
| 50 | $opt[CURLOPT_HTTPGET] = true; |
|
| 51 | unset($opt[CURLOPT_CUSTOMREQUEST]); |
|
| 52 | } |
|
| 53 | } else { |
|
| 54 | $opt[CURLOPT_CUSTOMREQUEST] = $http_method; |
|
| 55 | if($data_as_json or is_object($data)){ |
|
| 56 | $headers['Content-Type'] = 'application/json'; |
|
| 57 | $opt[CURLOPT_POSTFIELDS] = json_encode($data); |
|
| 58 | } else { |
|
| 59 | $opt[CURLOPT_POSTFIELDS] = http_build_query($data); |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| 63 | curl_setopt_array($ch,$opt); |
|
| 64 | $_harr = []; |
|
| @@ 38-57 (lines=20) @@ | ||
| 35 | ||
| 36 | $headers = array_merge($headers,static::$headers); |
|
| 37 | ||
| 38 | if($http_method == 'GET'){ |
|
| 39 | if($data && is_array($data)){ |
|
| 40 | $tmp = []; |
|
| 41 | $queried_url = $url; |
|
| 42 | foreach($data as $key=>$val) $tmp[] = $key.'='.$val; |
|
| 43 | $queried_url .= (strpos($queried_url,'?') === false) ? '?' : '&'; |
|
| 44 | $queried_url .= implode('&',$tmp); |
|
| 45 | $opt[CURLOPT_URL] = $queried_url; |
|
| 46 | $opt[CURLOPT_HTTPGET] = true; |
|
| 47 | unset($opt[CURLOPT_CUSTOMREQUEST]); |
|
| 48 | } |
|
| 49 | } else { |
|
| 50 | $opt[CURLOPT_CUSTOMREQUEST] = $http_method; |
|
| 51 | if($data_as_json or is_object($data)){ |
|
| 52 | $headers['Content-Type'] = 'application/json'; |
|
| 53 | $opt[CURLOPT_POSTFIELDS] = json_encode($data); |
|
| 54 | } else { |
|
| 55 | $opt[CURLOPT_POSTFIELDS] = http_build_query($data); |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||
| 59 | curl_setopt_array($ch,$opt); |
|
| 60 | $_harr = []; |
|