PHP code example of rits-tecnologia / melhorenvio-php-sdk

1. Go to this page and download the library: Download rits-tecnologia/melhorenvio-php-sdk 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/ */

    

rits-tecnologia / melhorenvio-php-sdk example snippets


$melhorenvio = new MelhorEnvio(env('MELHORENVIO_TOKEN'));

// repositories
$melhorenvio->shipments();
$melhorenvio->carriers();

$response = $melhorenvio->shipments()->calculate([
    'from' => [
        'postal_code' => '59082000',
    ],
    'to' => [
        'postal_code' => '59148485',
    ],
    'options' => [
        'receipt' => false,
        'own_hand' => false,
    ],
    'services' => '1,2',
    'products' => [
        [
            'id' => 'x',
            'width' => 11,
            'height' => 17,
            'length' => 11,
            'weight' => 0.3,
            'insurance_value' => 10.1,
            'quantity' => 1,
        ],
        [
            'id' => 'x',
            'width' => 20,
            'height' => 10,
            'length' => 11,
            'weight' => 0.5,
            'insurance_value' => 20.1,
            'quantity' => 2,
        ],
    ],
]);