PHP code example of tlissak / shipping

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

    

tlissak / shipping example snippets


composer 

use Shipping\Colissimo ;

$colissimo = new Colissimo('accountNumber','accountPassword') ;

$payloads = [
    'label'=>'CMD0001',
    'weight'=>1,
    'date'=>date('Y-m-d'),
    'shipper'=>[
        'companyName' => 'Your Company Name',
        'line2'       => '10 Postal Address',
        'countryCode' => 'FR',
        'city'        => 'PARIS',
        'zipCode'     => '75000',
        'email'       => '' //[email protected]
    ]
    ,'recipient'=>[
        'companyName' => 'recipient Company',
        'lastName'      => 'recipient Last name', //
        'firstName'     => 'recipient First name', //
        'line2'       => 'recipient Postal address' ,// Address
        'line3'       => '', //Additional Information
        'countryCode' => 'FR', //
        'city'        => 'PARIS', //
        'zipCode'     => '75000', //
        'phone'=>'0600000000', // 10 digits 
         'email'=>'', //recipient address
    ]
] ;


$response = $colissimo->generateLabel($payloads);
echo $response['tracking'] ; 
file_put_contents("colissimo.pdf",$response["pdf"]) ;

use Shipping\Chronopost ;

$payloads = [

    'shipper' => [
        'Adress1'=>'Your postal address'
        ,'Adress2'=>''
        ,'City'=>'Paris'
        ,'Civility'=>'M'
        ,'ContactName'=>'Your contact name' //Company
        ,'Country'=>'FR'
        ,'CountryName'=>'FRANCE'
        ,'Email'=>'[email protected]'
        ,'MobilePhone'=>''
        ,'Name'=>'Your name' //Company
        ,'Name2'=>''
        ,'Phone'=>'0600000000' // 10 digits
        ,'PreAlert'=>'0'
        ,'ZipCode'=>'75000'
    ]
    ,'customer'=>[
        'Adress1'=>'Your recepient postal address'
        ,'Adress2'=>''
        ,'City'=>'PARIS'
        ,'Civility'=>'M'
        ,'ContactName'=>'Contact Name'//Lissak
        ,'Country'=>'FR'
        ,'CountryName'=>'FRANCE'
        ,'Email'=>'[email protected]' //
        ,'MobilePhone'=>'0600000000' // 10 digits
        ,'Name'=>'First name'
        ,'Name2'=>'Last Name'
        ,'Phone'=>''
        ,'PreAlert'=>'1'
        ,'ZipCode'=>'75000'
    ]
    ,'recipient'=>[]
    ,'ref'=>[
        'shipperRef'=>'BC0000000000001'
    ]
    ,'skybill'=>[
        'productCode'=>'01' // For Chrono relay 13H use 86
        ,'shipDate'=>date('c')
        ,'shipHour'=>date('G')
        ,'weight'=>1 //KGM
        ,'service' => '0'
        ,'objectType'=>'MAR' //DOC / MAR Document ou Marchandise
        
    ]
] ;
$payloads['recipient'] = $payloads['customer'];

$chronopost = new Chronopost('TODO','TODO');


try {
    $result = $chronopost->genereEtiquette($payloads);
} catch (Exception $soapFault) {
    //var_dump($soapFault);
    exit($soapFault->faultstring);
}

if ($result->return->errorCode) {
    echo 'Erreur n° ' . $result->return->errorCode . ' : ' . $result->return->errorMessage;

} else {
    
    echo $result->return->skybillNumber ; 
file_put_contents("chronopost.pdf",$result->return->skybill) ;


}