PHP code example of opportus / sls-client

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

    

opportus / sls-client example snippets


use Opportus\SlsClient\Client;

$client = Client::create();

$requestParameters = [
    'contractNumber' => '111111',
    'password'       => '1111111',
    'outputFormat'   => [
        'x'                  => '0',
        'y'                  => '0',
        'outputPrintingType' => 'PDF_A4_300dpi',
    ],
    'letter' => [
        'service' => [
            'productCode' => 'DOM',
            'depositDate' => '2019-01-01',
        ],
        'parcel' => [
            'weight' => '1',
        ],
        'sender' => [
            'address' => [
                'companyName' => 'FOO',
                'line2'       => '1 RUE FOO',
                'countryCode' => 'FR',
                'city'        => 'FOO',
                'zipCode'     => '00000',
            ],
        ],
        'addressee' => [
            'address' => [
                'companyName' => 'BAR',
                'line2'       => '1 RUE BAR',
                'countryCode' => 'FR',
                'city'        => 'BAR',
                'zipCode'     => '00000',
            ],
        ],
    ],
];

$response = $client->generateLabel($requestParameters);

$response->getMessageId();    // '0'
$response->getLabel();        // <binary attachment>
$response->getParcelNumber(); // '6A11111111111'