Skip to content

Commit

Permalink
Merge pull request #29 from thomaschaaf/patch-2
Browse files Browse the repository at this point in the history
Finally got some time to check these... just to be clear, because `http_errors` is set to `false` in the guzzle client, the only exceptions that Guzzle will throw will be `GuzzleHttp\Exception\RequestException` or its sub-exceptions, `GuzzleHttp\Exception\ConnectException` and `GuzzleHttp\Exception\TooManyRedirectsException`. `GuzzleHttp\Exception\ClientException` (aka 400 errors) and `GuzzleHttp\Exception\ServerException` (aka 500 errors) are returned as responses to a request.
  • Loading branch information
Charlie Chrisman committed Feb 29, 2016
2 parents 3b9ccc7 + 6a6f645 commit e2f1412
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions plivo.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,19 @@ private function request($method, $path, $params = array()) {

if (!strcmp($method, "POST")) {
$body = json_encode($params, JSON_FORCE_OBJECT);
try {
$response = $client->post('', array(

$response = $client->post('', array(
'headers' => [ 'Content-type' => 'application/json'],
'body' => $body,
));
} catch (ClientException $e) {
echo $e->getRequest();
echo $e->getResponse();
}
} else if (!strcmp($method, "GET")) {
try {
$response = $client->get('', array(
$response = $client->get('', array(
'query' => $params,
));
} catch (ClientException $e) {
echo $e->getRequest();
echo $e->getResponse();
}
} else if (!strcmp($method, "DELETE")) {
try {
$response = $client->delete('', array(
$response = $client->delete('', array(
'query' => $params,
));
} catch (ClientException $e) {
echo $e->getRequest();
echo $e->getResponse();
}
}
$responseData = json_decode($response->getBody(), true);
$status = $response->getStatusCode();
Expand Down

0 comments on commit e2f1412

Please sign in to comment.