PHP code example of bubbstore / correios

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

    

bubbstore / correios example snippets




use bubbstore\Correios\Zipcode;

$zipcode = new Zipcode('14940000');
echo '<pre>' . json_encode($zipcode->find()) . '</pre>';




use bubbstore\Correios\CorreiosQuote;
use bubbstore\Correios\Exceptions\CorreiosQuoteException;

try
{
	$quote = new CorreiosQuote();

	$items = [
		[16, 16, 16, .3, 2], // largura, altura, comprimento, peso e quantidade
		[16, 16, 16, .3, 2], // largura, altura, comprimento, peso e quantidade
	];

	$result = $quote->setOrigin('14940000')
					->setDestination('14900000')
					->setServices(['4014', '4510'])
					->setItems($items)
					->setCompanyCode('16181271')
					->setPassword('11570480')
					->calculate();

	echo '<pre>' . json_encode($result) . '</pre>';

} catch ( CorreiosQuoteException $e )
{
	echo $e->getMessage();
}



use bubbstore\Correios\CorreiosTracking;
use bubbstore\Correios\Exceptions\CorreiosTrackingException;

try {

	$tracking = new CorreiosTracking('PO548836895BR');
	$result = $tracking->find();

	exit(var_dump($result));

} catch (CorreiosTrackingException $e) {
	echo $e->getMessage();
}