update php petstore sample code

This commit is contained in:
William Cheng
2015-03-15 22:06:42 +08:00
parent 6bc8de1230
commit bcdee4e038

View File

@@ -127,27 +127,16 @@ class APIClient {
// Handle the response
if ($response_info['http_code'] == 0) {
<<<<<<< HEAD
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) {
=======
throw new Exception("TIMEOUT: api call to " . $url .
" took more than 5s to return" );
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
>>>>>>> add logic to handle all 2xx response code, bug fix for string response,
$data = json_decode($response);
if (json_last_error() > 0) { // if response is a string
$data = $response;
}
} else if ($response_info['http_code'] == 401) {
<<<<<<< HEAD
throw new APIClientException("Unauthorized API request to " . $url .
": " . json_decode($response)->message, 0, $response_info, $response);
=======
throw new Exception("Unauthorized API request to " . $url .
": ".serialize($response));
>>>>>>> add logic to handle all 2xx response code, bug fix for string response,
": " . serialize($response), 0, $response_info, $response);
} else if ($response_info['http_code'] == 404) {
$data = null;
} else {