To retrieve the HTTP response status code from a Guzzle request in PHP, you can use the getStatusCode()
method provided by the response object.
Here's an example:
use GuzzleHttp\Client;
$client = new Client();
$response = $client->request('GET', 'https://api.example.com');
$status = $response->getStatusCode();
In this example, we first create an instance of the Guzzle client. Then, we make a GET request to the specified URL. The $response
variable contains the response object returned by Guzzle.
Finally, we retrieve the status code using the getStatusCode()
method and store it in the $status
variable. You can now use the $status
variable in your code as needed.