use GuzzleHttp\Client; $client = new Client(); $response = $client->get('https://api.example.com/users'); echo $response->getStatusCode(); // 200 echo $response->getBody();
$response = $client->get('https://api.example.com/users', [ 'query' => [ 'page' => 2, 'limit' => 10 ] ]);
$response = $client->post('https://api.example.com/users', [ 'form_params' => [ 'name' => 'John Doe', 'email' => 'john.doe@example.com', ] ]);This example shows how to use the `post()` method to send a POST request to the API endpoint with form data. The `form_params` option is used to specify the form data as an array of key-value pairs. Overall, the PHP Guzzle library is a powerful tool for interacting with APIs and making HTTP requests in PHP. Its ease of use, flexibility and robustness make it a top choice for PHP developers.