Answers for "handle guzzle authentication exceptions"

PHP
0

guzzle catch exceptions

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\ConnectException;

$client = new Client();

try{
	$response = $client->request('GET', 'http://github.com');
}
catch (ConnectException $e) {
	// Connection exceptions are not caught by RequestException
	echo "Internet, DNS, or other connection error\n";
    die;
}
catch (RequestException $e) {
	echo "Request Exception\n";
    die;
}
// deal with your $reponse here
Posted by: Guest on March-29-2021

Code answers related to "handle guzzle authentication exceptions"

Browse Popular Code Answers by Language