支持快递鸟、快递100的快递查询SDK
- 无人维护,接盘维护一下,尽量保证及时维护
$ composer require asundust/express
在使用本扩展之前,你需要去 快递100 或者 快递鸟 注册申请,获取到APP_id和APP_key。
use Asundust\Express\Express100;
$express = new Express100('app_id','app_key');
$info = $express->track($tracking_code, $shipping_code, $phone); //快递单号 物流公司编号 收件人手机号(顺丰必填 其他快递选填)
示例:
{
"message": "ok",
"nu": "888888888888",
"ischeck": "1",
"condition": "F00",
"com": "shunfeng",
"status": "200",
"state": "3",
"data": [
{
"time": "2019-03-08 19:11:51",
"ftime": "2019-03-08 19:11:51",
"context": "[安高广场速运营业点]快件已发车"
},
{
"time": "2019-03-08 18:56:12",
"ftime": "2019-03-08 18:56:12",
"context": "[安高广场速运营业点]快件在【合肥蜀山区安高广场营业点】已装车,准备发往 【合肥经开集散中心】"
},
{
"time": "2019-03-08 18:50:52",
"ftime": "2019-03-08 18:50:52",
"context": "[安高广场速运营业点]顺丰速运 已收取快件"
}
]
}
use Asundust\Express\ExpressBird;
$express = new ExpressBird('app_id','app_key');
$info = $express->track($tracking_code, $shipping_code,$order_code); //快递单号 物流公司编号 订单编号(选填)
示例:
{
"LogisticCode": "8888888888888888",
"ShipperCode": "YTO",
"Traces": [
{
"AcceptStation": "【四川省直营市场部公司】 取件人: 四川省直营市场部41 已收件",
"AcceptTime": "2019-03-21 11:03:40"
},
{
"AcceptStation": "【四川省直营市场部公司】 已收件",
"AcceptTime": "2019-03-21 13:45:01"
},
{
"AcceptStation": "【成都转运中心】 已收入",
"AcceptTime": "2019-03-21 22:40:01"
}
],
"State": "3",
"OrderCode": "",
"EBusinessID": "100000",
"Success": true
}
use Asundust\Express\Express;
$express = new Express($app_id,$app_key,$type); //$type支持类型'express100'、'expressbird'
//快递鸟$additional=['order_code'=>111111] 快递100 $additional=['phone'=>'18899996666']
$info = $express->track($tracking_code, $shipping_code,$additional); ////查询物流 快递单号 额外参数
在 Laravel 中使用也是同样的安装方式,配置写在 config/services.php
中:
.
.
.
'express' => [
'id' => env('EXPRESS_ID'),
'key' => env('EXPRESS_KEY'),
'type' => env('EXPRESS_TYPE'),
],
然后在 .env
中配置 EXPRESS_ID
、EXPRESS_KEY
、EXPRESS_TYPE
;
EXPRESS_ID=xxxxxxxxxxxxxxxxxxxxx
EXPRESS_KEY=xxxxxxxxxxxxxxxxxxxxx
EXPRESS_TYPE=express100
可以用两种方式来获取 Asundust\Express\Express
实例:
.
.
.
public function edit(Express $express)
{
$response = $express->track('888888888','YTO');
}
.
.
.
.
.
.
public function edit()
{
$response = app('express')->track('888888888','YTO');
}
.
.
.
MIT