{"id":20719714,"url":"https://github.com/slince/shipment-tracking","last_synced_at":"2025-04-23T14:20:43.224Z","repository":{"id":55066671,"uuid":"98408417","full_name":"slince/shipment-tracking","owner":"slince","description":":sparkles: A flexible shipment tracking library for multi carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100,递四方 etc.","archived":false,"fork":false,"pushed_at":"2018-07-03T10:13:43.000Z","size":53,"stargazers_count":29,"open_issues_count":1,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T00:24:50.107Z","etag":null,"topics":["china-post","dhl-ecommerce","epacket","parcel","shipment","shipment-tracker","tracking","usps"],"latest_commit_sha":null,"homepage":"http://mypackage.co/tracking?orderNo=9037866297519\u0026trackingNum=LW489083733CN","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slince.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-26T09:58:45.000Z","updated_at":"2025-03-13T22:41:20.000Z","dependencies_parsed_at":"2022-08-14T10:50:48.488Z","dependency_job_id":null,"html_url":"https://github.com/slince/shipment-tracking","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fshipment-tracking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fshipment-tracking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fshipment-tracking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slince%2Fshipment-tracking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slince","download_url":"https://codeload.github.com/slince/shipment-tracking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250447982,"owners_count":21432166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["china-post","dhl-ecommerce","epacket","parcel","shipment","shipment-tracker","tracking","usps"],"created_at":"2024-11-17T03:18:06.305Z","updated_at":"2025-04-23T14:20:43.203Z","avatar_url":"https://github.com/slince.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shipment Tracking SDK \n\n[![Build Status](https://img.shields.io/travis/slince/shipment-tracking/master.svg?style=flat-square)](https://travis-ci.org/slince/shipment-tracking)\n[![Coverage Status](https://img.shields.io/codecov/c/github/slince/shipment-tracking.svg?style=flat-square)](https://codecov.io/github/slince/shipment-tracking)\n[![Latest Stable Version](https://img.shields.io/packagist/v/slince/shipment-tracking.svg?style=flat-square\u0026label=stable)](https://packagist.org/packages/slince/shipment-tracking)\n[![Scrutinizer](https://img.shields.io/scrutinizer/g/slince/shipment-tracking.svg?style=flat-square)](https://scrutinizer-ci.com/g/slince/shipment-tracking/?branch=master)\n\nA flexible and awesome shipment tracking library for several carriers like DHL eCommerce, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100\n\n## Installation\n\nInstall via composer\n\n```bash\n$ composer require slince/shipment-tracking\n```\n\n## Table of Contents\n\n- [DHL eCommerce](#dhl-ecommerce)\n- [YanWen Express(燕文物流)](#yanwen-express燕文物流)\n- [E邮宝(Epacket、EUP)、E包裹、E特快、国际EMS](#中国邮政)\n- [快递100](#快递100)\n- [USPS](#usps)\n- [递四方](#递四方)\n\n## Basic Usage\n\n### DHL eCommerce\n\n```php\n\n$tracker = new Slince\\ShipmentTracking\\DHLECommerce\\DHLECommerceTracker(CLIENT_ID, PASSWORD);\n\ntry {\n   $shipment = $tracker-\u003etrack('CNAQV100168101');\n   \n   if ($shipment-\u003eisDelivered()) {\n       echo \"Delivered\";\n   }\n   echo $shipment-\u003egetOrigin();\n   echo $shipment-\u003egetDestination();\n   print_r($shipment-\u003egetEvents());  //print the shipment events\n   \n} catch (Slince\\ShipmentTracking\\Foundation\\Exception\\TrackException $exception) {\n    exit('Track error: ' . $exception-\u003egetMessage());\n}\n\n```\nThe above code will get access token automatically for shipment information.\n\n#### Access Token\n\n```php\n$shipment = $tacker-\u003etrack('CNAQV100168101);\n$accessToken = $tracker-\u003egetAccessToken(); //You can save this for the next query\n\n//... to do\n\ntry{\n    $tracker-\u003esetAccessToken($accessToken); //Set the access token; the tracker will not send requst for the access token\n    $shipment = $tacker-\u003etrack('CNAQV100168101);\n} catch (Slince\\ShipmentTracking\\DHLECommerce\\Exception\\InvalidAccessTokenException $exception) {\n     $accessToken = $tracker-\u003egetAccessToken(true); // If the access token is invalid, refresh it.\n     $shipment = $tacker-\u003etrack('CNAQV100168101);\n     //... to do\n} catch (Slince\\ShipmentTracking\\Foundation\\Exception\\TrackException $exception) {\n    exit('Track error: ' . $exception-\u003egetMessage());\n}\n```\n\n### YanWen Express(燕文物流)\n\n```php\n\n$tracker = new Slince\\ShipmentTracking\\YanWenExpress\\YanWenTracker(KEY, 'en');\n\ntry {\n   $shipment = $tracker-\u003etrack('CNAQV100168101');\n   \n   if ($shipment-\u003eisDelivered()) {\n       echo \"Delivered\";\n   }\n   echo $shipment-\u003egetOrigin();\n   echo $shipment-\u003egetDestination();\n   print_r($shipment-\u003egetEvents());  //print the shipment events\n   \n} catch (Slince\\ShipmentTracking\\Foundation\\Exception\\TrackException $exception) {\n    exit('Track error: ' . $exception-\u003egetMessage());\n}\n\n```\n\n### 中国邮政 \n\n适用中邮旗下E邮宝(Epacket、EUP)、E包裹、E特快、国际EMS产品\n\n\n```php\n\n$tracker = new Slince\\ShipmentTracking\\EMS\\EMSTracker(AUTHENTICATE, 'en');\n\ntry {\n   $shipment = $tracker-\u003etrack('CNAQV100168101');\n   \n   print_r($shipment-\u003egetEvents());  //print the shipment events\n   \n} catch (Slince\\ShipmentTracking\\Foundation\\Exception\\TrackException $exception) {\n    exit('Track error: ' . $exception-\u003egetMessage());\n}\n\n```\n\n注意：该库并不支持查询国内EMS包裹信息，相关文档主页[http://shipping.ems.com.cn/apiIndex](http://shipping.ems.com.cn/apiIndex)\n\n### 快递100\n\n```php\n\n$tracker = new Slince\\ShipmentTracking\\KuaiDi100\\KuaiDi100Tracker(APPKEY, 'shunfeng'); //承运商名称并不是标准的承运商代码，实际承运商代码请到kuaidi100.com查看\n\ntry {\n   $shipment = $tracker-\u003etrack('CNAQV100168101');\n   \n   if ($shipment-\u003eisDelivered()) {\n       echo \"Delivered\";\n   }\n   print_r($shipment-\u003egetEvents());  //print the shipment events\n   \n} catch (Slince\\ShipmentTracking\\Foundation\\Exception\\TrackException $exception) {\n    exit('Track error: ' . $exception-\u003egetMessage());\n}\n\n```\n快递100的key需要自行申请，免费版的key在查询申通顺丰之类的单号时会受限，需要企业版才可以；附上快递100[文档](https://www.kuaidi100.com/openapi/api_post.shtml)\n\n### USPS\n\n```php\n\n$tracker = new Slince\\ShipmentTracking\\USPS\\USPSTracker(USER_ID);\n\ntry {\n   $shipment = $tracker-\u003etrack('CNAQV100168101');\n   \n   if ($shipment-\u003eisDelivered()) {\n       echo \"Delivered\";\n   }\n   print_r($shipment-\u003egetEvents());  //print the shipment events\n   \n} catch (Slince\\ShipmentTracking\\Foundation\\Exception\\TrackException $exception) {\n    exit('Track error: ' . $exception-\u003egetMessage());\n}\n\n```\n\nYou can get your user id on the following url.\n\n[https://www.usps.com/business/web-tools-apis/welcome.htm](https://www.usps.com/business/web-tools-apis/welcome.htm)\n\n### 递四方\n\n```php\n\n$tracker = new Slince\\ShipmentTracking\\FourPartyExpress\\FourPartyExpressTracker(APPKEY, APPSECRET);\n\ntry {\n   $shipment = $tracker-\u003etrack('CNAQV100168101');\n   \n   print_r($shipment-\u003egetEvents());  //print the shipment events\n   \n} catch (Slince\\ShipmentTracking\\Foundation\\Exception\\TrackException $exception) {\n    exit('Track error: ' . $exception-\u003egetMessage());\n}\n\n```\n\nAPPKEY和APPSECRET 需要到递四方官网注册APP,审核之后即可获取到该参数；\n\n## License\n \nThe MIT license. See [MIT](https://opensource.org/licenses/MIT)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslince%2Fshipment-tracking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslince%2Fshipment-tracking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslince%2Fshipment-tracking/lists"}