2017 © Pedro Peláez
 

library shipment-tracking

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

image

slince/shipment-tracking

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  • Tuesday, July 3, 2018
  • by slince
  • Repository
  • 3 Watchers
  • 9 Stars
  • 681 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 14 Versions
  • 46 % Grown

The README.md

Shipment Tracking SDK

Build Status Coverage Status Latest Stable Version Scrutinizer, (*1)

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100, (*2)

Installation

Install via composer, (*3)

$ composer require slince/shipment-tracking

Table of Contents

Basic Usage

DHL eCommerce


$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\Foundation\Exception\TrackException $exception) { exit('Track error: ' . $exception->getMessage()); }

The above code will get access token automatically for shipment information., (*4)

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\Foundation\Exception\TrackException $exception) {
    exit('Track error: ' . $exception->getMessage());
}

YanWen Express(燕文物流)


$tracker = new Slince\ShipmentTracking\YanWenExpress\YanWenTracker(KEY, 'en'); 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\Foundation\Exception\TrackException $exception) { exit('Track error: ' . $exception->getMessage()); }

中国邮政

适用中邮旗下E邮宝(Epacket、EUP)、E包裹、E特快、国际EMS产品, (*5)


$tracker = new Slince\ShipmentTracking\EMS\EMSTracker(AUTHENTICATE, 'en'); try { $shipment = $tracker->track('CNAQV100168101'); print_r($shipment->getEvents()); //print the shipment events } catch (Slince\ShipmentTracking\Foundation\Exception\TrackException $exception) { exit('Track error: ' . $exception->getMessage()); }

注意:该库并不支持查询国内EMS包裹信息,相关文档主页http://shipping.ems.com.cn/apiIndex, (*6)

快递100


$tracker = new Slince\ShipmentTracking\KuaiDi100\KuaiDi100Tracker(APPKEY, 'shunfeng'); //承运商名称并不是标准的承运商代码,实际承运商代码请到kuaidi100.com查看 try { $shipment = $tracker->track('CNAQV100168101'); if ($shipment->isDelivered()) { echo "Delivered"; } print_r($shipment->getEvents()); //print the shipment events } catch (Slince\ShipmentTracking\Foundation\Exception\TrackException $exception) { exit('Track error: ' . $exception->getMessage()); }

快递100的key需要自行申请,免费版的key在查询申通顺丰之类的单号时会受限,需要企业版才可以;附上快递100文档, (*7)

USPS


$tracker = new Slince\ShipmentTracking\USPS\USPSTracker(USER_ID); try { $shipment = $tracker->track('CNAQV100168101'); if ($shipment->isDelivered()) { echo "Delivered"; } print_r($shipment->getEvents()); //print the shipment events } catch (Slince\ShipmentTracking\Foundation\Exception\TrackException $exception) { exit('Track error: ' . $exception->getMessage()); }

You can get your user id on the following url., (*8)

https://www.usps.com/business/web-tools-apis/welcome.htm, (*9)

递四方


$tracker = new Slince\ShipmentTracking\FourPartyExpress\FourPartyExpressTracker(APPKEY, APPSECRET); try { $shipment = $tracker->track('CNAQV100168101'); print_r($shipment->getEvents()); //print the shipment events } catch (Slince\ShipmentTracking\Foundation\Exception\TrackException $exception) { exit('Track error: ' . $exception->getMessage()); }

APPKEY和APPSECRET 需要到递四方官网注册APP,审核之后即可获取到该参数;, (*10)

License

The MIT license. See MIT, (*11)

The Versions

03/07 2018

dev-master

9999999-dev

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

20/11 2017

2.2.4

2.2.4.0

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

18/11 2017

2.2.3

2.2.3.0

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

17/11 2017

2.2.2

2.2.2.0

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

01/11 2017

2.2.1

2.2.1.0

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

01/11 2017

2.2.0

2.2.0.0

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

26/10 2017

2.1.0-beta3

2.1.0.0-beta3

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

26/10 2017

2.1.1

2.1.1.0

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

04/09 2017

2.1.0

2.1.0.0

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

18/08 2017

2.1.0-beta2

2.1.0.0-beta2

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

18/08 2017

2.1.0-beta1

2.1.0.0-beta1

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

11/08 2017

2.0.0

2.0.0.0

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

09/08 2017

2.0.0-beta1

2.0.0.0-beta1

A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking dhl tracker shipment kuaidi100 parcel 快递100 epacket dhl ecommerce e邮宝 燕文物流 e包裹 yanwen express e特快 国际ems

27/07 2017

1.0.0

1.0.0.0

A flexible and shipment tracking library for multi carriers.

  Sources   Download

MIT

The Requires

 

The Development Requires

by tao

tracking usps tracker shipment parcel epacket china post