NiZerin
/
kuaidi
Public
-
Notifications
You must be signed in to change notification settings - Fork 0
-
Star 3
📦 A wrapper library of multiple free express tracking APIs in China.
License
3
stars
0
forks
Branches
Tags
Activity
Star
Notifications
You must be signed in to change notification settings
NiZerin/kuaidi
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branches Tags
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Latest commitHistory7 Commits | ||||
examples | examples | |||
lib | lib | |||
.gitignore | .gitignore | |||
.styleci.yml | .styleci.yml | |||
.travis.yml | .travis.yml | |||
LICENSE | LICENSE | |||
README.md | README.md | |||
composer.json | composer.json | |||
Repository files navigation
📦 集成「快递100」、「快递网」、「快递鸟」三家快递查询接口,并统一调用方式。
❤️ 本项目 GitHub。
- 目录
- 小试牛刀
- 使用方法
- 0. 安装
- 1. 创建运单
- 2. 查询
- 3. 获得数据
- 结语
- 声明
小试牛刀
注意:本扩展包内所有快递公司名称,均不带结尾 物流
/ 快递
/ 快运
/ 速递
/ 速运
等字眼。
克隆本仓库,并执行 composer install
安装所需依赖。
在命令行内运行。
php examples/index.php <运单编号> [快递公司名称]
其中,快递公司名称可省略;效果如下:
使用方法
0. 安装
composer require nizerin/kuaidi
1. 创建运单
$waybill = new \Kuaidi\Waybill(
'运单编号',
'快递公司名称'
);
「快递100」支持自动识别,可不填快递公司名称。
2. 查询
(new \Kuaidi\Trackers\Kuaidi100)->track($waybill);
(new \Kuaidi\Trackers\Kuaidiwang)->track($waybill);
(new \Kuaidi\Trackers\Kuaidiniao('Business ID', 'APP Key'))->track($waybill);
通常三选一即可,推荐使用「快递100」。
若查询过程出错,或接口返回失败将会抛出 Kuaidi\TrackingException
。
3. 获得数据
// 获取状态,所有状态列表见 `Waybill::STATUS_*` 常量。
$waybill->getStatus();
// 获取详情,支持直接 foreach / while / 数组下标 形式访问。
$waybill->getTraces();
实际项目中,可自行封装辅助函数以便于使用。
结语
这个扩展包的初衷,是因为各家快递查询接口支持的快递公司不同,有部分接口不稳定 / 缺失小众快递公司的支持;公司产品需要稳定且支持率高,所以封装出来一套比较统一的快递查询接口,包装各家的 API,也方便以后进行扩展。
目前已经在生产环境稳定使用三个月左右,解除无关依赖后修改放出,供大家参考使用。
如果你有新的公共接口 / 原有接口出现问题,欢迎 Issue 和 PR,不胜感激。
关于命名,考虑到国内外环境差距大,此扩展包多数只在国内使用;所以干脆用本地化的词语,简单好记:Kuaidi
。
声明
接口来源于网络,本扩展包仅为包装和收集,仅供学习参考;对于数据准确性、接口可用性不作保证;一切法律问题自行承担。
About
📦 A wrapper library of multiple free express tracking APIs in China.
Resources
Readme
License
Activity
Stars
3
stars
Watchers
1
watching
Forks
0
forks
Report repository
Releases 1
1.0.0
Latest
Packages 0
No packages published
Languages
- PHP 100.0%