PHP code example of merinsky / balikobot

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

    

merinsky / balikobot example snippets


use Merinsky\Balikobot\Balikobot;

define('API_USER', '...');
define('API_KEY', '...');
define('SHOP', 100);

// create instance of the class
$balikobot = new Balikobot(API_USER, API_KEY, SHOP);

// add package
$package = $balikobot->service(Balikobot::SHIPPER_PPL, 4, [
        Balikobot::OPTION_ORDER => '2017000001',
    ])
        ->customer('Jan Novak', 'Jankovcova 2', 'Praha', '17000', '+420773145254', '[email protected]')
        ->add();

/*
dump($package);
[ 
    carrier_id => 40458564564,
    package_id => 7338,
    label_url => http://pdf.balikobot.cz/ppl/eNorpelvMdA1trS0NAJcMA_plao.,
    status => 200,
]
*/

// order packages collection
$response = $balikobot->order(Balikobot::SHIPPER_PPL, [$package['package_id'], ...]);

/*
dump($response);
[
    order_id => 788,
    handover_url => http://pdf.balikobot.cz/ppl/eNrpelMTIyMaA1r6elNANcMA_xAn4.,
    labels_url => http://pdf.balikobot.cz/ppl/eNrpelIyMdAgfrSrpelVcMA_wAn0.,
    status => 200,
]
*/

$response = $balikobot->getServices(Balikobot::SHIPPER_PPL);

/*
dump($response);
[
    2 => PPL Parcel Connect,
    3 => PPL Parcel CZ Dopolední balík,
    4 => PPL Parcel CZ Private,
    8 => PPL Parcel CZ Business,
    9 => PPL Parcel CZ Private - Večerní doručení,
    15 => PPL Firemní paleta,
    19 => PPL Soukromá paleta,
]
*/

$response = $balikobot->getOptions(Balikobot::SHIPPER_DPD);

/*
dump($response);
[
    0 => price,
    1 => real_order_id,
    2 => sms_notification,
    3 => branch_id,
    4 => del_insurance,
    5 => note,
    6 => weight,
]
*/

$response = $balikobot->getBranches(Balikobot::SHIPPER_CP, 'NP');

/*
dump($response);
[
    67152 => [
        name => Hluboké Mašůvky,
        city => Hluboké Mašůvky,
        street => 230,
        zip => 67152,
        country => CZ,
        type => branch
    ],
    74282 => [
    ]
    ...
]
*/

$response = $balikobot->getZipCodes(Balikobot::SHIPPER_ULOZENKA, 2);

/*
dump($response);
[
    0 => 97401,
    1 => 97405,
    2 => 97411,
    ...
]
*/

$response = $balikobot->getLabels(Balikobot::SHIPPER_PPL, [1258, 544, 5454, ...]);

/*
dump($response);
http://pdf.balikobot.cz/ppl/eNsrMadfMdA1trS0NffcMA_vAnw.
*/

$response = $balikobot->overview(Balikobot::SHIPPER_PPL);

/*
dump($response);
[
    0 => [
        eshop_id => 20170000071490299455,
        carrier_id => 13805004931509,
        package_id => 5732,
        label_url => http://pdf.balikobot.cz/dpd/eNfaMTIyMdAtwrt1BFwzDWECQA..,
    ],     
    ...
]
*/

$response = $balikobot->trackPackage(Balikobot::SHIPPER_PPL, '40425465434');

/*
dump($response);
[
    0 => 01.07.2014 11:11 1383 Hradec Kralove - Pouchov (CZ)  6211385 doručeno : BALIKOBOT  CZ •50311 • 1383 351 327,
    1 => 01.07.2014 06:37 1383 Hradec Kralove - Pouchov (CZ)rozvoz  CZ •50311 • 1383 351 327,
    2 => 01.07.2014 06:32 1383 Hradec Kralove - Pouchov (CZ)příjem na depo  CZ •50311 • 1383 64 327,
    3 => 30.06.2014 16:56 1381 Ricany (CZ)vyzvednutí  CZ •50311 • 1383 686 327,
]
*/

$response = $balikobot->trackPackageLast(Balikobot::SHIPPER_PPL, '40425465434');

/*
dump($response);
[
    status_id => 2,
    status_text => Zásilka je doručována příjemci.,
]
*/