1. Go to this page and download the library: Download hafael/php-http-client 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/ */
hafael / php-http-client example snippets
fael\HttpClient\Client;
class MyCustomClient extends Client {
/**
* The Client (not Eastwood)
*
* @param string $apiKey
* @param string $baseUrl
*/
public function __construct(string $apiKey, string $baseUrl)
{
$this->setApiKey($apiKey);
$this->setBaseUrl($baseUrl);
}
}
$customClient = new MyCustomClient(
'API_KEY',
'https://myapiendpoint.com.br',
);
//Get Api Method
$response = $customClient->exampleOfApiResource()
->getExampleResourceMethod();
var_dump($response->json());