Created
October 11, 2018 12:58
-
-
Save odixon/16422dff4c5e91344ca13f4126d2e151 to your computer and use it in GitHub Desktop.
Guzzle with http errors off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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