kruegge82 / dhl-php-rest-sdk
注意:这是DPDHL集团包裹德国邮递API的规范。此REST Web服务允许商业客户按需创建运货标签。
v2.1.10.1
2024-08-29 07:55 UTC
Requires
- php: ^7.4 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
README
注意:这是DPDHL集团包裹德国邮递API的规范。此REST Web服务允许商业客户按需创建运货标签。
安装与使用
要求
PHP 7.4及更高版本。也应在PHP 8.0中正常工作。
Composer
要通过Composer安装绑定,请将以下内容添加到composer.json
{ "repositories": [ { "type": "vcs", "url": "https://github.com/kruegge82/dhl-php-rest-sdk.git" } ], "require": { "kruegge82/dhl-php-rest-sdk": "*@dev" } }
然后运行composer install
手动安装
下载文件并包含autoload.php
<?php require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
入门
请遵循安装过程,然后运行以下命令
<?php require_once(__DIR__ . '/vendor/autoload.php'); $apiInstance = new kruegge82\DHL\Api\GeneralApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(['http_errors'=>false]) ); try { $result = $apiInstance->rootGet(); print_r($result); } catch (Exception $e) { echo 'Exception when calling GeneralApi->rootGet: ', $e->getMessage(), PHP_EOL; }
API端点
所有URI均相对于https://api-eu.dhl.com/parcel/de/shipping/v2
模型
- BankAccount
- Commodity
- Consignee
- ContactAddress
- Country
- CustomsDetails
- Dimensions
- Document
- GetManifestData
- LabelDataResponse
- Locker
- MultipleManifestResponse
- POBox
- PostOffice
- RequestStatus
- ResponseItem
- ServiceInformation
- ServiceInformationAmp
- ServiceInformationBackend
- Shipment
- ShipmentDetails
- ShipmentManifestingRequest
- ShipmentOrderRequest
- ShipmentShipper
- Shipper
- ShipperReference
- ShortResponseItem
- SingleManifestResponse
- VAS
- VASCashOnDelivery
- VASDhlRetoure
- VASIdentCheck
- ValidationMessageItem
- Value
- Weight
Authorization
API定义的认证方案
BasicAuth
- 类型:HTTP基本认证
ApiKey
- 类型:API密钥
- API密钥参数名称:dhl-api-key
- 位置:HTTP头
测试
要运行测试,使用
composer install vendor/bin/phpunit