Instantly share code, notes, and snippets.

Embed
What would you like to do?
Guzzle with http errors off
<?php
// create client
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', $someApi, ['http_errors' => false]);
// check http status code
if ($res->getStatusCode() != 200) {
// handle it
}
$res = $client->request('GET', $anotherApi, ['http_errors' => false]);
if ($res->getStatusCode() != 200) {
// handle it
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment