use Drupal\Core\Http\Client; $client = \Drupal::httpClient(); $response = $client->request('GET', 'http://example.com'); $body = (string) $response->getBody();
use Drupal\Core\Http\Client; $client = \Drupal::httpClient(); $response = $client->request('POST', 'http://example.com', [ 'form_params' => [ 'name' => 'John Doe', 'email' => 'johndoe@example.com', ], ]); $body = (string) $response->getBody();This example sends a POST request to example.com with form data and retrieves the response body. The php Drupal httpClient library is a part of the Drupal Core library which provides various APIs and libraries for building Drupal websites.