PHP code example of schiggi / gls-cee-shipping-api

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

    

schiggi / gls-cee-shipping-api example snippets



  


    $api = new GLS\API([
        'username'          => 'teszt',
        'password'          => 'teszt',
        'client_number'     => '100000004',
        'country_code'      => 'HU'
    ]);


  $api = new GLS\API([
    'username'          => 'teszt',
    'password'          => 'teszt',
    'client_number'     => '100000004',
    'country_code'      => 'HU',
    'log_dir'  => dirname(__FILE__).'/'
  ]);
 


// Parcel generation. Data will be validated before sending.
$parcel_generate[] = array(
    'SenderName' => 'Company Kft.',
    'SenderAddress' => 'Ady Endre ut 104',
    'SenderCity' => 'Budapest',
    'SenderZipcode' => '1072',
    'SenderCountry' => 'HU',
    // Not mandatory
    'SenderContact' => 'Contact Axanne',
    'SenderPhone' => '06202156156',
    'SenderEmail' => '[email protected]',
    //
    'ConsigName' => 'Alex Schikalow',
    'ConsigAddress' => 'Teszt ut 1',
    'ConsigCity' => 'Budapest',
    'ConsigZipcode' => '1025',
    'ConsigCountry' => 'HU',
    // Not mandatory
    'ConsigContact' => 'Alex Schikalow',
    'ConsigPhone' => '06301245879',
    'ConsigEmail' => '[email protected]',
    //

    'ClientRef' => '14050',
    'CodAmount' => 0,
    'CodRef' => '',
    'Pcount' => 1,
    'PickupDate' => '2018-02-26',
    'Services' => array(
        "24H" => "",
        "FDS" => "[email protected]",
        "FSS" => "+362012345648",
    ),
);

// Will return the parcel numbers for each clientRef order from GLS or error message
$parcel_numbers = $api->getParcelNumbers($parcel_generate);

var_dump($parcel_numbers);
Array
(
  [14050] => 00201084696
)


// Array of parcel numbers from GLS. Client / order ids optional. Can also be a numeric array.
$parcel_numbers = array(
    '14050' => 00201084696
);

// Returns array with success message and pdf stream
$printed_parcels = $api->getParcelLabels($prepared_parcels);

var_dump($printed_parcels);
Array
(
    [status] => 'success'
    [error_description] => 'Error Description. Empty, if success'
    [pdf] => is streamed labels. Use echo and correct pdf header to display
)


$api = new GLS\API([
    'username'          => 'teszt',
    'password'          => 'teszt',
    'client_number'     => '100000004',
    'country_code'      => 'HU-TEST',
    'label_paper_size'  => 'A4_2x2',
]);


// Array of parcel numbers from GLS. Order references are optional. Can be numerical array.
$delete_parcels = Array
(
    '14050' => '00209053638',
    '14051' => '00209053637'
);

// Returns array with success message or error description
$deleted_parcels = $api->deleteParcels($delete_parcels);

var_dump($deleted_parcels);
Array
(
    [00209053638] => 'success'
    [00209053637] => 'Parcel already deleted'
)


// returns status message as string for parcel_number. One number at a time.
$status_msg = $api->getParcelStatus('123456789');



// returns url link for parcel number. One number at a time.
$status_msg = $api->$api->getTrackingUrl('123456789');