nyra/dhl
最新稳定版本:1.0.2
Composer 安装命令:
composer require nyra/dhl
包简介
Deutsche Post INTERNETMARKE (Post & Paket Deutschland)
README 文档
README
Install
composer require nyra/dhl
Usage
Quick start:
<?php require_once __DIR__ . '/vendor/autoload.php'; use Nyra\Dhl\Auth\Credentials; use Nyra\Dhl\DhlClient; use Nyra\Dhl\Dto\Address; use Nyra\Dhl\Dto\AddressBinding; use Nyra\Dhl\Dto\ShoppingCartPDFPosition; use Nyra\Dhl\Dto\LabelPdfRequest; use Nyra\Dhl\Dto\VoucherLayout; use Nyra\Dhl\Dto\VoucherPosition; // Create client with your credentials (use environment vars in production) $dhl = DhlClient::create( credentials: new Credentials( clientId: 'your-client-id', clientSecret: 'your-client-secret', username: 'your-username', password: 'your-password' ), ); // Retrieve tracking information for a shipment $tracking = $dhl->tracking->shipments->retrieve([ 'trackingNumber' => '000000000000000000000', ]); // Create an Internetmarke shopping cart $shoppingCart = $dhl->internetmarke->shoppingCart->create(); // Checkout a PDF with positions from the shopping cart $response = $dhl->internetmarke->labels->checkoutPdf( request: new LabelPdfRequest( total: 5, positions: [ new ShoppingCartPDFPosition( productCode: 298, voucherLayout: VoucherLayout::ADDRESS_ZONE, position: new VoucherPosition(labelX: 1, labelY: 1, page: 1), address: new AddressBinding( sender: new Address( name: 'Max Mustermann', addressLine1: 'Postfach 12345', city: 'Bonn', postalCode: '53056', country: 'DEU', additionalName: 'Example Sender Ltd.' ), receiver: new Address( name: 'Max Mustermann', addressLine1: 'Musterstraße 1', city: 'Musterstadt', postalCode: '12345', country: 'DEU' ) ) ) ], shopOrderId: $shoppingCart->shopOrderId, pageFormatId: 77, ) ); print_r($response);
Testing
composer test
Notes
- HTTP client defaults to Guzzle via PSR-18; you can pass any PSR-18 client and PSR-16-like token cache implementing
TokenCacheInterface. - Error responses are thrown as
ApiExceptionwith parsed error payload when status code >= 400.
统计信息
- 总下载量: 54
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-27