PHP code example of feliperoberto / non-official-correios-api

1. Go to this page and download the library: Download feliperoberto/non-official-correios-api 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/ */

    

feliperoberto / non-official-correios-api example snippets

 php
\Correios\CEP::buscar($cep);
\Correios\Rastreio::localizar($codigo_rastreio);
 console
php composer.phar install feliperoberto/non-official-correios-api
 php

$_GET['cep'])){
	header('Content-Type: text/json; charset=UTF-8');
	$endereco = \Correios\CEP::buscar(preg_replace('/[^0-9]/', '', $_GET['cep']));
	die(json_encode($endereco ? $endereco[0] : null));
}elseif(isset($_GET['endereco'])){
	header('Content-Type: text/json; charset=UTF-8');
	die(json_encode(\Correios\CEP::buscar($_GET['endereco'])));
}elseif(isset($_GET['codigo_rastreio'])){
	header('Content-Type: text/json; charset=UTF-8');
	die(json_encode(\Correios\Rastreio::localizar($_GET['codigo_rastreio'])));
}