slince/shipment-tracking-dhl-ecommerce
Composer 安装命令:
composer require slince/shipment-tracking-dhl-ecommerce
包简介
A flexible and shipment tracking library for DHL eCommerce.
README 文档
README
A flexible and shipment tracking library for DHL eCommerce and DHL eCommerce(Registered)
Installation
Install via composer
$ composer require slince/shipment-tracking-dhl-ecommerce
Basic Usage
$tracker = new Slince\ShipmentTracking\DHLECommerce\DHLECommerceTracker(CLIENT_ID, PASSWORD); try { $shipment = $tracker->track('CNAQV100168101'); if ($shipment->isDelivered()) { echo "Delivered"; } echo $shipment->getOrigin(); echo $shipment->getDestination(); print_r($shipment->getEvents()); //print the shipment events } catch (Slince\ShipmentTracking\Exception\TrackException $exception) { exit('Track error: ' . $exception->getMessage()); }
The above code will get access token automatically for shipment information.
Access Token
$shipment = $tacker->track('CNAQV100168101); $accessToken = $tracker->getAccessToken(); //You can save this for the next query //... to do try{ $tracker->setAccessToken($accessToken); //Set the access token; the tracker will not send requst for the access token $shipment = $tacker->track('CNAQV100168101); } catch (Slince\ShipmentTracking\DHLECommerce\Exception\InvalidAccessTokenException $exception) { $accessToken = $tracker->getAccessToken(true); // If the access token is invalid, refresh it. $shipment = $tacker->track('CNAQV100168101); //... to do } catch (Slince\ShipmentTracking\Exception\TrackException $exception) { exit('Track error: ' . $exception->getMessage()); }
License
The MIT license. See MIT
统计信息
- 总下载量: 429
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-27