1. Go to this page and download the library: Download nibblelab/ibgeapiclient-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/ */
nibblelab / ibgeapiclient-php example snippets
$ composer
try
{
$api = new IBGEApiClient();
$response = $api->buscarRegioes();
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarRegiaoById('1');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarRegioesByIds(array('1','3'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarUFs();
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarUFById('31');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarUFsByIds(array('31','32'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarUFsByRegiao('3');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarUFsByRegioes(array('2','3'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMesoRegioes();
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMesoRegiaoById('1101');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMesoRegioesByIds(array('1101','1102'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMesoRegioesByRegiao('1');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMesoRegioesByRegioes(array('1','2'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMesoRegioesByUF('31');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMesoRegioesByUFs(array('31','27'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegioes();
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegiaoById('11001');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegioesByIds(array('11001','11002'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegioesByRegiao('1');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegioesByRegioes(array('1','2'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegioesByUF('31');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegioesByUFs(array('31','27'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegioesByMesoRegiao('1102');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMicroRegioesByMesoRegioes(array('1101','1102'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipios();
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipioById('3170206');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByIds(array('3170206','5108352'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByRegiao('1');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByRegioes(array('1','2'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByUF('31');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByUFs(array('31','27'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByMesoRegiao('1102');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByMesoRegioes(array('1101','1102'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByMicroRegiao('11001');
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
try
{
$api = new IBGEApiClient();
$response = $api->buscarMunicipiosByMicroRegioes(array('11001','11002'));
foreach($response->getData() as $r) {
echo ' nome = ' . $r->getNome() . "\n"; # printe o nome
}
} catch (Exception $ex) {
echo $ex->getMessage();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.