1. Go to this page and download the library: Download jhernandes/correios 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/ */
jhernandes / correios example snippets
use Correios\Correios;
// CEP deve ter 8 dígitos com mascara ou sem
$cepOrigem = '01156-060';
$cepDestino = '88034-685';
// Defina o Peso em Quilos (kg) (float)
$peso = 0.50;
// Altura, Largura e Comprimento em centimetros (cm) (integer)
$altura = 5;
$largura = 12;
$comprimento = 8;
$servicos = array(
Correios::SEDEX,
Correios::PAC,
);
$correios = new Correios(
$servicos,
$cepOrigem,
$cepDestino,
$peso,
$altura,
$largura,
$comprimento
);
$fretes = $correios->calculaFretes();
foreach($fretes as $frete) {
print_r($frete);
}
// Para recuperar os dados do frete:
$valor = $frete->getValor();
$servico = $frete->getServico();
$codigo = $frete->getCodigo();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.