PHP code example of hardsystem / correios-lib
1. Go to this page and download the library: Download hardsystem/correios-lib 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/ */
hardsystem / correios-lib example snippets
ardsystem\Correios\Correios;
$correios = new Correios();
try {
$endereco = $correios->consultarCep('01001000');
echo "CEP: " . $endereco->getCep() . "\n";
echo "Logradouro: " . $endereco->getLogradouro() . "\n";
echo "Bairro: " . $endereco->getBairro() . "\n";
echo "Cidade: " . $endereco->getLocalidade() . "\n";
echo "UF: " . $endereco->getUf() . "\n";
echo "DDD: " . $endereco->getDdd() . "\n";
} catch (\Hardsystem\Correios\Exceptions\ConsultaCepException $e) {
echo "Erro ao consultar CEP: " . $e->getMessage() . "\n";
}