PHP code example of myparcelbe / sdk

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

    

myparcelbe / sdk example snippets


$myParcelCollection = new \MyParcelBE\Sdk\src\Helper\MyParcelCollection();

$consignment = (new \MyParcelBE\Sdk\src\Model\Repository\MyParcelConsignmentRepository())
    ->setApiKey('api_key_from_MyParcel_backoffice')
    ->setReferenceId('Order 1203')
    ->setCountry('BE')
    ->setPerson('Piet Hier')
    ->setCompany('Piet BV')
    ->setFullStreet('Plein 1945 55b')
    ->setPostalCode('2231JE')
    ->setCity('Amsterdam')
    ->setEmail('[email protected]');
    
$myParcelCollection
    ->addConsignment($consignment)
    ->setPdfOfLabels()
    ->downloadPdfOfLabels()
    ->setUserAgent('name_of_cms', '1.0');

$myParcelCollection = new \MyParcelBE\Sdk\src\Helper\MyParcelCollection();

$consignment = (new \MyParcelBE\Sdk\src\Model\Repository\MyParcelConsignmentRepository())
    ->setApiKey('api_key_from_MyParcel_backoffice')
    ->setReferenceId('Order 1203')
    ->setCountry('BE')
    ->setPerson('Piet Hier')
    ->setCompany('Piet BV')
    ->setFullStreet('Plein 1945 55b')
    ->setPostalCode('2231JE')
    ->setPackageType(1)
    ->setCity('Amsterdam')
    ->setEmail('[email protected]')
    ->setPhone('+31 (0)634213465')
    ->setLargeFormat(true)
    ->setOnlyRecipient(true)
    ->setSignature(true)
    ->setReturn(true)
    ->setInsurance(250)
    ->setLabelDescription('Order 10034');
    
$myParcelCollection
    ->addConsignment($consignment)

    ->setStreet('Plein 1945')
    ->setNumber((string)55)
    ->setBoxNumber('b')

$myParcelCollection->createConcepts();

$myParcelCollection->setPdfOfLabels();
$myParcelCollection->downloadPdfOfLabels();

$myParcelCollection
    ->setLinkOfLabels()
    ->getLinkOfLabels()

$consignment->getMyParcelConsignmentId();

$status = $consignment->getStatus();

$barcode = $consignment->getBarcode();

$myParcelCollection = new \MyParcelBE\Sdk\src\Helper\MyParcelCollection();

foreach ($yourShipments as $yourShipment) {

    $consignment = (new \MyParcelBE\Sdk\src\Model\Repository\MyParcelConsignmentRepository())
        ->setApiKey('api_key_from_MyParcel_backoffice')
        ->setReferenceId($yourShipment->getOrderId()
        ->setName('Piet Hier');
        /** @todo; set all info */
        
    $myParcelCollection
        ->setUserAgent('name_of_cms', '1.0')
        ->addConsignment($consignment)
}

$consignment = (new \MyParcelBE\Sdk\src\Model\Repository\MyParcelConsignmentRepository())
    ->setApiKey('api_key_from_MyParcel_backoffice')
    ->setReferenceId('Order 1203'); // or setMyParcelConsignmentId(123456)

$myParcelCollection
    ->addConsignment($consignment)
    ->setLatestData();

$consignments = $myParcelCollection
    ->getConsignments();

$firstConsignment = $consignments[0];

$status = $firstConsignment->getStatus();
$barcode = $firstConsignment->getBarcode();