sonnenglas / mydhl-php-sdk
MyDHL REST API(DHL快递)非官方PHP SDK
0.3.2
2023-01-16 18:39 UTC
Requires
- php: ~8.0
- ext-json: *
- guzzlehttp/guzzle: ~7.1
- ramsey/uuid: ^4.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13.2
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.9.11
- phpstan/phpstan-deprecation-rules: ^1.1.1
- phpstan/phpstan-phpunit: ^1.3.3
- phpstan/phpstan-strict-rules: ^1.4.5
- phpunit/phpunit: ^9.5
README
用于使用DHL快递REST API(MyDHL API)的PHP库。
注意:它仅支持DHL提供的最新REST API。不支持SOAP API。
支持的服务
用法
差异
检索运费
use Sonnenglas\MyDHL\MyDHL; use Sonnenglas\MyDHL\ValueObjects\RateAddress; use Sonnenglas\MyDHL\ValueObjects\Package; $testMode = true; $myDhl = new MyDHL('username', 'password', $testMode); $rateService = $myDhl->getRateService(); $originAddress = new RateAddress( countryCode: 'DE', postalCode: '10117', cityName: 'Berlin', ); $destinationAddress = new RateAddress( countryCode: 'DE', postalCode: '20099', cityName: 'Hamburg', ); $package = new Package( weight: 10, // kg height: 20, // cm length: 10, // cm width: 30, // cm ); $shippingDate = new DateTimeImmutable('2021-01-15 12:00:00'); $rates = $rateService->setAccountNumber('99999999') ->setOriginAddress($originAddress) ->setDestinationAddress($destinationAddress) ->setPlannedShippingDate($shippingDate) ->setPackage($package) ->setNextBusinessDay(false) ->setCustomsDeclarable(false) ->getRates();
所有用法示例