项目作者: shipcore-nl

项目描述 :
DHL Parcel API PHP Bindings
高级语言: PHP
项目地址: git://github.com/shipcore-nl/dhlparcel-api-php.git
创建时间: 2017-10-20T08:36:06Z
项目社区:https://github.com/shipcore-nl/dhlparcel-api-php

开源协议:MIT License

下载


DHL Parcel API PHP Bindings

PHP Library to use DHL Parcel API as documented on https://api-gw.dhlparcel.nl/docs/.

Install instructions

  1. composer require shipcore-nl/dhlparcel-api-php

Example

Create Shipment Label

  1. $userId = 'YOUR_USER_ID'
  2. $key = 'YOUR_KEY';
  3. $sandbox = true;
  4. $dhl = new \ShipCore\DHLParcel\Api($userId, $key, null, $sandbox);
  5. $labelSpecification = \ShipCore\DHLParcel\Entity\Request\LabelSpecification::fromDataArray([
  6. 'labelId' => ShipCore\DHLParcel\Util\UUID::generateUUID(),
  7. 'orderReference' => 'myReference',
  8. 'parcelTypeKey' => 'SMALL',
  9. 'receiver' => [
  10. 'name' => [
  11. 'firstName' => 'John',
  12. 'lastName' => 'Doe',
  13. 'companyName' => 'ACME Corp.',
  14. 'additionalName' => 'Benelux'
  15. ],
  16. 'address' => [
  17. 'countryCode' => 'NL',
  18. 'postalCode' => '3542AD',
  19. 'city' => 'Utrecht',
  20. 'street' => 'Reactorweg',
  21. 'number' => '25',
  22. 'isBusiness' => true,
  23. 'addition' => 'A'
  24. ],
  25. 'email' => 'mrparcel@dhlparcel.nl',
  26. 'phoneNumber' => '0031612345678'
  27. ],
  28. 'shipper' => [
  29. 'name' => [
  30. 'firstName' => 'John',
  31. 'lastName' => 'Doe',
  32. 'companyName' => 'ACME Corp.',
  33. 'additionalName' => 'Benelux'
  34. ],
  35. 'address' => [
  36. 'countryCode' => 'NL',
  37. 'postalCode' => '3542AD',
  38. 'city' => 'Utrecht',
  39. 'street' => 'Reactorweg',
  40. 'number' => '25',
  41. 'isBusiness' => true,
  42. 'addition' => 'A'
  43. ],
  44. 'email' => 'mrparcel@dhlparcel.nl',
  45. 'phoneNumber' => '0031612345678'
  46. ],
  47. 'accountId' => '01234567',
  48. 'options' => [
  49. [
  50. 'key' => 'DOOR'
  51. ]
  52. ],
  53. 'returnLabel' => false,
  54. 'pieceNumber' => 1,
  55. 'quantity' => 1,
  56. 'automaticPrintDialog' => true
  57. ]);
  58. $response = $dhl->createLabel($labelSpecification);
  59. print_r($response);