PHP code example of marko / http-guzzle
1. Go to this page and download the library: Download marko/http-guzzle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
marko / http-guzzle example snippets
use Marko\Http\Contracts\HttpClientInterface;
class ApiClient
{
public function __construct(
private HttpClientInterface $httpClient,
) {}
public function fetchData(): array
{
$response = $this->httpClient->get('https://api.example.com/data', [
'headers' => ['Accept' => 'application/json'],
]);
return $response->json();
}
}