PHP code example of shipcore-nl / postnl-api-php
1. Go to this page and download the library: Download shipcore-nl/postnl-api-php 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/ */
shipcore-nl / postnl-api-php example snippets
use ThirtyBees\PostNL\PostNL;
use ThirtyBees\PostNL\Entity\Customer;
use ThirtyBees\PostNL\Entity\Address;
use ThirtyBees\PostNL\Entity\Shipment;
use ThirtyBees\PostNL\Entity\Dimension;
::create([
'AddressType' => '02',
'City' => 'Hoofddorp',
'CompanyName' => 'PostNL',
'Countrycode' => 'NL',
'HouseNr' => '42',
'Street' => 'Siriusdreef',
'Zipcode' => '2132WT',
]),
'Email' => '[email protected] ',
'Name' => 'Michael',
]);
$apikey = 'YOUR_API_KEY_HERE';
$sandbox = true;
$postnl = new PostNL($customer, $apikey, $sandbox);
$barcode = $postnl->generateBarcodeByCountryCode('NL');
$shipment = Shipment::create([
'Addresses' => [
Address::create([
'AddressType' => '01',
'City' => 'Utrecht',
'Countrycode' => 'NL',
'FirstName' => 'Peter',
'HouseNr' => '9',
'HouseNrExt' => 'a bis',
'Name' => 'de Ruijter',
'Street' => 'Bilderdijkstraat',
'Zipcode' => '3521VA',
]),
],
'Barcode' => $barcode,
'Dimension' => new Dimension('2000'),
'ProductCodeDelivery' => '3085',
]);
$label = $postnl->generateLabel($shipment, 'GraphicFile|PDF', true);
var_dump($label);die();