PHP code example of ogestor / busca-via-cep

1. Go to this page and download the library: Download ogestor/busca-via-cep 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/ */

    

ogestor / busca-via-cep example snippets


BrunoCouty\BuscaViaCep\BuscaViaCepServiceProvider::class,

$cep = new \BrunoCouty\BuscaViaCep\Services\Cep();
$response = $cep->busca('04538133');

[  
   {  
      "cep":"04538-133",
      "logradouro":"Avenida Brigadeiro Faria Lima",
      "complemento":"de 3253 ao fim - lado ímpar",
      "bairro":"Itaim Bibi",
      "localidade":"São Paulo",
      "uf":"SP",
      "unidade":"",
      "ibge":"3550308",
      "gia":"1004"
   }
]

{  
   "message":"Client error: `GET https:\/\/viacep.com.br\/ws\/04538133a\/json\/unicode\/` resulted in a `400 Bad Request` response:\n<h2>Bad Request (400)<\/h2>\n",
   "code":400
}