41

GitHub - uuk020/logistics: PHP 获取快递物流信息

 5 years ago
source link: https://github.com/uuk020/logistics
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Logistics

无需授权和配置, 简单便捷查询运单快递信息

Build Status

环境需求

  • PHP >= 7.0

安装

$ composer require wythe/logistics -vvv

使用

use Wythe\Logistics\Logistics
$logistics = new Logisitics()

快递100接口获取物流信息

$logistics->getLogisticsByName('12313131231'); // 第二参数不设,则默认快递100接口
$logistics->getLogisticsByName('12313131231', 'kuaidi100');

示例:

[  
   "status" => "200",
   "message" => "OK",
   "error_code" => "3",
   "data" => [
       ["time" => "2018-12-21 17:51:32", "ftime" => "2018-12-21 17:51:32", "context" => "已签收", "location" => NULL],
       ["time" => "2018-12-21 17:51:32", "ftime" => "2018-12-21 16:51:32", "context" => "派件中", "location" => NULL],
       ["time" => "2018-12-21 17:51:32", "ftime" => "2018-12-20 13:51:32" ,"context" => "已到达", "location" => NULL]
    ],
   "logistics_company" => "shentong",
   "logistics_bill_no" => "12313131231",
]

百度接口获取物流信息

$logistics->getLogisticsByName('12313131231', 'baidu');

示例:

[  
   "status" => "0",
   "message" => "",
   "error_code" => "0",
   "data" => [
       ["time" => "1545444420", "desc" => "已签收"],
       ["time" => "1545441977", "desc" => "派件中"],
       ["time" => "1545438199", "desc" => "已到达"]
    ],
   "logistics_company" => "shentong",
   "logistics_bill_no" => "12313131231",
]

多接口获取物流信息

$logistics->getLogisticsByArray('12313131231'); // 只要一个接口请求成功, 停止请求下一个接口
$logistics->getLogisticsByArray('12313131231', ['baidu', 'kuaidi100']);

示例:

[
   "kuaidi100" => [
       "info" => [  
           status" => "200",
           "message" => "OK",
           "error_code" => "3",
           "data" => [
                ["time" => "2018-12-21 17:51:32", "ftime" => "2018-12-21 17:51:32", "context" => "已签收", "location" => NULL],
                ["time" => "2018-12-21 17:51:32", "ftime" => "2018-12-21 16:51:32", "context" => "派件中", "location" => NULL],
                ["time" => "2018-12-21 17:51:32", "ftime" => "2018-12-20 13:51:32" ,"context" => "已到达", "location" => NULL]
            ],
           "logistics_company" => "shentong",
           "logistics_bill_no" => "12313131231",
        ]
   ]
]

参数说明

array getLogisticsByName(string $code, $queryName = 'kuaidi100')

array getLogisticsByArray(string $code, $queryArray = ['kuaidi100', 'baidu'])
  • $code - 运单号
  • $queryName - 接口名称, 目前支持百度(baidu), 快递100(kuaidi100)
  • $queryArray - 接口数组, 如: ['kuaidi100', 'baidu']

参考

最后

欢迎提出issue

License

MIT


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK