1. Go to this page and download the library: Download andreoneres/brasilapi-php 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/ */
andreoneres / brasilapi-php example snippets
rasilApi\Client;
$brasilApi = new Client();
$address = $brasilApi->cep()->get('01001000');
rasilApi\Client;
use BrasilApi\Endpoints\Abstracts\Endpoint;
class Hope extends Endpoint
{
public function getList(): array
{
return $this->client->request("/hopes/list");
}
}
$brasilApi = new Client();
$brasilApi->addEndpoint("hope", Hope::class);
$address = $brasilApi->hope()->getList();
try {
$address = $brasilApi->cep()->get('01001000');
} catch (BrasilApiException $e) {
echo $e->getMessage(); // Retorna a mensagem de erro da API
echo $e->getCode(); // Retorna o código HTTP da API
echo $e->getErrors(); // Retorna os erros retornados pela API
echo $e->getRawResponse(); // Retorna a resposta bruta da API
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.