Merge pull request #485 from wing328/fix_php_string_response

minor bug fixes and enhancement to Swagger.php
This commit is contained in:
Tony Tam 2015-03-15 21:02:37 -07:00
commit 156ec2a2dd
2 changed files with 10 additions and 4 deletions

View File

@ -129,11 +129,14 @@ class APIClient {
if ($response_info['http_code'] == 0) {
throw new APIClientException("TIMEOUT: api call to " . $url .
" took more than 5s to return", 0, $response_info, $response);
} else if ($response_info['http_code'] == 200) {
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
$data = json_decode($response);
if (json_last_error() > 0) { // if response is a string
$data = $response;
}
} else if ($response_info['http_code'] == 401) {
throw new APIClientException("Unauthorized API request to " . $url .
": " . json_decode($response)->message, 0, $response_info, $response);
": " . serialize($response), 0, $response_info, $response);
} else if ($response_info['http_code'] == 404) {
$data = null;
} else {

View File

@ -129,11 +129,14 @@ class APIClient {
if ($response_info['http_code'] == 0) {
throw new APIClientException("TIMEOUT: api call to " . $url .
" took more than 5s to return", 0, $response_info, $response);
} else if ($response_info['http_code'] == 200) {
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
$data = json_decode($response);
if (json_last_error() > 0) { // if response is a string
$data = $response;
}
} else if ($response_info['http_code'] == 401) {
throw new APIClientException("Unauthorized API request to " . $url .
": " . json_decode($response)->message, 0, $response_info, $response);
": " . serialize($response), 0, $response_info, $response);
} else if ($response_info['http_code'] == 404) {
$data = null;
} else {