shipcore-nl / postnl-api-php
PostNL REST API PHP 绑定
0.1.0-alpha1
2017-09-18 08:34 UTC
This package is not auto-updated.
Last update: 2024-09-21 17:06:22 UTC
README
关于
这个PHP库旨在为PostNL的REST和SOAP API提供一种简单的方式,使您能够将应用程序与PostNL连接起来。通过在处理货运信息时抽象掉不必要的复杂性并提高容错性,您可以在几分钟内开始使用PostNL。
在底层,这个库使用异步通信和负载分割来提高性能。
重要通知
PHP绑定可以连接到PostNL的SOAP和REST API。
这个库仍在开发中,但希望条形码、标签和确认功能将很快完成。
状态
说明
- 克隆此存储库
- 可选:运行
composer require guzzlehttp/guzzle使用Guzzle而不是直接使用cURL - 运行
composer install(没有composer?请访问 https://composer.php.ac.cn/) - 您已经准备好了!本README中包含一些简单的示例。
示例
使用默认REST API创建标签
<?php use ThirtyBees\PostNL\PostNL; use ThirtyBees\PostNL\Entity\Customer; use ThirtyBees\PostNL\Entity\Address; use ThirtyBees\PostNL\Entity\Shipment; use ThirtyBees\PostNL\Entity\Dimension; require_once __DIR__.'/vendor/autoload.php'; $customer = Customer::create([ 'CollectionLocation' => '123456', 'CustomerCode' => 'DEVC', 'CustomerNumber' => '11223344', 'ContactPerson' => 'Lesley', 'Address' => Address::create([ 'AddressType' => '02', 'City' => 'Hoofddorp', 'CompanyName' => 'PostNL', 'Countrycode' => 'NL', 'HouseNr' => '42', 'Street' => 'Siriusdreef', 'Zipcode' => '2132WT', ]), 'Email' => 'michael@thirtybees.com', '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();