firstred / postnl-api-php
PostNL REST API PHP 绑定
Requires
- php: ^8.1
- composer/ca-bundle: ^1.0
- guzzlehttp/promises: ^1.0 || ^2.0
- guzzlehttp/psr7: ^1.7 || ^2.0
- paragonie/hidden-string: ^2.0
- php-http/discovery: ^1.9.1
- psr/cache: ^1.0 || ^2.0 || ^3.0
- psr/clock: ^1.0
- psr/http-factory: ^1.0
- psr/http-factory-implementation: *
- psr/http-message: ^1.0
- psr/http-message-implementation: *
- psr/log: ^1.0.2 || ^2.0 || ^3.0
- setasign/fpdf: ^1.8
- setasign/fpdi: ^2.3
- symfony/deprecation-contracts: ^2.1 || ^3.0
Requires (Dev)
- cache/void-adapter: ^1.2
- friendsofphp/php-cs-fixer: ^3.16
- guzzlehttp/guzzle: ^7.2
- monolog/monolog: ^3.0
- php-http/mock-client: ^1.3
- phpunit/phpunit: ^10.0
- symfony/clock: ^6.0
- symfony/dotenv: ^6.0
Suggests
- abbadon1334/phpdoc-to-rst: Build the documentation
- giggsey/libphonenumber-for-php: To automatically format and check phone numbers -- supports ^8.12
- guzzlehttp/guzzle: One of the most popular HTTP clients available -- supports ^7.0
- guzzlehttp/psr7: One of the most popular HTTP clients available -- supports ^7.0
- php-http/httplug: Required if you want to use an alternative PSR-18, async or HTTPlug Client
- php-http/message-factory: Required if you want to use an alternative PSR-18, async or HTTPlug Client
- psr/http-factory: Required if you want to use an alternative PSR-18, async or HTTPlug Client
- symfony/http-client: Another popular HTTP client you can use natively -- supports ^5.4
- v2.0.x-dev
- v2.0.11
- v2.0.10
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0-beta.6
- v2.0.0-beta.5
- v2.0.0-beta.4
- v2.0.0-beta.3
- v2.0.0-beta.2
- v2.0.0-beta.1
- v1.4.x-dev
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.x-dev
- v1.3.19
- v1.3.18
- v1.3.17
- v1.3.16
- v1.3.15
- v1.3.14
- v1.3.13
- v1.3.12
- v1.3.11
- v1.3.10
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.x-dev
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.2.0-beta.8
- v1.2.0-beta.7
- v1.2.0-beta.6
- v1.2.0-beta.5
- v1.2.0-beta.4
- v1.2.0-beta.3
- v1.2.0-beta.2
- v1.2.0-beta.1
- v1.2.0-alpha.4
- v1.2.0-alpha.3
- v1.2.0-alpha.2
- v1.2.0-alpha.1
- v1.2.0-alpha.0
- v1.1.x-dev
- v1.1.0
- v1.0.0
- 1.0.0-beta.1
- dev-null-logger
- dev-abandoned-v2.0.x-attempt
This package is auto-updated.
Last update: 2024-09-18 10:58:31 UTC
README
关于
这个 PostNL REST API 的非官方 PHP 库旨在提供一种简单的方法将您的应用程序与 PostNL 连接起来。通过在处理货运信息时抽象出不必要的复杂性并提高容错性,您可以在几分钟内开始使用 PostNL。
在底层,此库使用异步通信和有效载荷拆分来提高性能。
状态
* PostNL::getTimeframesAndNearestLocations
可以用作具有更多功能的替代品:[链接](https://postnl-php.readthedocs.io/en/v1.4.x/quickstart.html#requesting-timeframes-location-and-delivery-date-at-once)
说明
- 克隆此仓库
- 运行
composer install
(没有 composer?请访问 [链接](https://getcomposer.org.cn/)) - 可选地运行
composer require guzzlehttp/guzzle
以使用 Guzzle 而不是直接使用 cURL - 您已经准备好开始使用了!本 README 中提供了一个简单的示例。请查看完整文档以获取 [快速入门指南](https://postnl-php.readthedocs.io/en/v1.2.x/quickstart.html)。
文档
示例
允许用户使用默认 REST API 下载标签
<?php use Firstred\PostNL\PostNL; use Firstred\PostNL\Entity\Customer; use Firstred\PostNL\Entity\Address; use Firstred\PostNL\Entity\Shipment; use Firstred\PostNL\Entity\Dimension; require_once __DIR__.'/vendor/autoload.php'; $customer = Customer::create([ 'CollectionLocation' => '123456', 'CustomerCode' => 'DEVC', 'CustomerNumber' => '11223344', 'ContactPerson' => 'Peter', 'Address' => Address::create([ 'AddressType' => '02', 'City' => 'Hoofddorp', 'CompanyName' => 'PostNL', 'Countrycode' => 'NL', 'HouseNr' => '42', 'Street' => 'Siriusdreef', 'Zipcode' => '2132WT', ]), 'Email' => 'info@voorbeeld.nl', 'Name' => 'Michael', ]); $apikey = 'YOUR_API_KEY_HERE'; $sandbox = false; $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(/* weight */ '2000'), 'ProductCodeDelivery' => '3085', ]); header('Content-Type: application/pdf'); header('Content-Disposition: attachment; filename="label.pdf"'); echo base64_decode($postnl->generateLabel( /* The actual shipment */ $shipment, /* The output format */ 'GraphicFile|PDF', /* Immediately confirm the shipment */ true ) ->getResponseShipments()[0] ->getLabels()[0] ->getContent() ); exit;
完整文档
完整文档可以在本页面上找到:[链接](https://postnl-php.readthedocs.io/)
构建文档
生成文档分为两个步骤
- 生成此库中所有 PHP 类的参考 RST 文件。
- 生成可以浏览的 HTML 输出。
生成 PHP 类参考
生成参考依赖于一个相当旧的库。从 require-dev
中先移除其他依赖可能是在安装 abbadon1334/phpdoc-to-rst
时最好的解决方案。
"require-dev": {
},
然后安装 PHPdoc 到 RST 工具。
composer require abbadon1334/phpdoc-to-rst -W
此仓库包含一个简单的 PHP 文件,它使用上述提到的工具以编程方式生成参考 RST 文件。它还移动了一些文件以将参考集成到其余文档中。
只需运行(已在 PHP 8.2 上测试)
php ./build-docs-reference.php
生成最终 HTML 输出
文档自动构建并托管在 readthedocs.io 上。您可以通过安装 Sphinx 并运行以下命令来构建本地 HTML 副本:[链接](https://sphinx-doc.cn/en/master/usage/installation.html)
pip install -r docs/requirements.txt
来安装需求,然后
sphinx-build -b html docs builddir
在 builddir
目录中构建 HTML 输出。
许可
此库已使用 MIT 许可证授权。
完整许可证文本
MIT 许可证(MIT)。版权所有(c)2017-2023 Michael Dekker ([链接](https://github.com/firstred))
以下条件下,任何人都可以免费获得本软件及其相关文档文件(以下简称“软件”)的副本,并且可以不受限制地处理软件,包括但不限于以下权利:使用、复制、修改、合并、发布、分发、再许可和/或出售软件的副本,并允许向软件提供方提供软件的人这样做,前提是满足以下条件
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
本软件按“原样”提供,不提供任何形式的保证,无论是明示的还是隐含的,包括但不限于适销性、特定目的适用性和非侵权性。在任何情况下,作者或版权所有者不应对任何索赔、损害或其他责任负责,无论这些责任是基于合同、侵权或其他任何原因,这些责任源于、因之产生于或与软件或软件的使用或其他方式有关。