@@ -115,31 +115,31 @@ discard block |
||
| 115 | 115 | call_user_func($this->_curl_callback, $ch, $params, $headers, $method); |
| 116 | 116 | } |
| 117 | 117 | switch (strtoupper($method)) { |
| 118 | - case 'PUT': |
|
| 118 | + case 'PUT': |
|
| 119 | 119 | case 'PATCH': |
| 120 | 120 | case 'DELETE': |
| 121 | 121 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method)); |
| 122 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); |
|
| 122 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); |
|
| 123 | 123 | break; |
| 124 | 124 | case 'POST': |
| 125 | 125 | curl_setopt($ch, CURLOPT_POST, true); |
| 126 | - if ($this->json === true) { |
|
| 126 | + if ($this->json === true) { |
|
| 127 | 127 | $params = json_encode($params); |
| 128 | - } |
|
| 129 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
| 128 | + } |
|
| 129 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); |
|
| 130 | 130 | break; |
| 131 | 131 | case 'GET': |
| 132 | 132 | curl_setopt($ch, CURLOPT_HTTPGET, true); |
| 133 | - if (!empty($params)) { |
|
| 134 | - $url .= '?' . http_build_query($params); |
|
| 135 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 136 | - } |
|
| 133 | + if (!empty($params)) { |
|
| 134 | + $url .= '?' . http_build_query($params); |
|
| 135 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 136 | + } |
|
| 137 | 137 | break; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $headers[] = $this->_api_key_var.$this->_api_key; |
| 141 | 141 | if ($this->json === true) { |
| 142 | - $headers[] = 'Content-Type: application/json'; |
|
| 142 | + $headers[] = 'Content-Type: application/json'; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | $this->response = curl_exec($ch); |
| 152 | 152 | if (curl_errno($ch)) { |
| 153 | - $this->curlErrno = curl_errno($ch); |
|
| 154 | - $this->curlError = curl_error($ch); |
|
| 155 | - curl_close($ch); |
|
| 156 | - return; |
|
| 153 | + $this->curlErrno = curl_errno($ch); |
|
| 154 | + $this->curlError = curl_error($ch); |
|
| 155 | + curl_close($ch); |
|
| 156 | + return; |
|
| 157 | 157 | } |
| 158 | 158 | $this->curlInfo = curl_getinfo($ch); |
| 159 | 159 | curl_close($ch); |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | foreach (explode("\n", $raw_headers) as $i => $h) { |
| 169 | 169 | $h = explode(':', $h, 2); |
| 170 | 170 | if (isset($h[1])) { |
| 171 | - if (!isset($headers[$h[0]])) { |
|
| 172 | - $headers[$h[0]] = trim($h[1]); |
|
| 173 | - } elseif (is_array($headers[$h[0]])) { |
|
| 174 | - $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); |
|
| 175 | - } else { |
|
| 176 | - $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); |
|
| 177 | - } |
|
| 178 | - $key = $h[0]; |
|
| 171 | + if (!isset($headers[$h[0]])) { |
|
| 172 | + $headers[$h[0]] = trim($h[1]); |
|
| 173 | + } elseif (is_array($headers[$h[0]])) { |
|
| 174 | + $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); |
|
| 175 | + } else { |
|
| 176 | + $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); |
|
| 177 | + } |
|
| 178 | + $key = $h[0]; |
|
| 179 | 179 | } else { |
| 180 | - if (substr($h[0], 0, 1) == "\t") { |
|
| 181 | - $headers[$key] .= "\r\n\t".trim($h[0]); |
|
| 182 | - } elseif (!$key) { |
|
| 183 | - $headers[0] = trim($h[0]); |
|
| 184 | - } |
|
| 180 | + if (substr($h[0], 0, 1) == "\t") { |
|
| 181 | + $headers[$key] .= "\r\n\t".trim($h[0]); |
|
| 182 | + } elseif (!$key) { |
|
| 183 | + $headers[0] = trim($h[0]); |
|
| 184 | + } |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | return $headers; |