Code Monkey home page Code Monkey logo

logistics's Introduction

Logistics

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

Build Status

环境需求

  • PHP >= 7.0

安装

$ composer require wythe/logistics -vvv

使用

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

快递100接口获取物流信息

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

示例:

[
   'kuaidi100' => [
       'channel' => 'kuaidi100',
       "status" => 'success',
       'result' => [
           [
               'status' => 200,
               'message'  => 'OK',
               'error_code' => 0,
               'data' => [
                   ['time' => '2019-01-09 12:11', 'context' => '仓库-已签收'],
                   ['time' => '2019-01-07 12:11', 'context' => '广东XX服务点'],
                   ['time' => '2019-01-06 12:11', 'context' => '广东XX转运中心']
               ],
               'logistics_company' => '申通快递',
               'logistics_bill_no' => '12312211'
           ]
       ]
   ]
]

爱查快递接口获取物流信息

$logistics->query('12313131231', 'ickd');
$logistics->query('12313131231', ['ickd']);

示例:

[
   'ickd' => [
       'channel' => 'ickd',
       "status" => 'success',
       'result' => [
           [
               'status' => 200,
               'message'  => 'OK',
               'error_code' => 0,
               'data' => [
                   ['time' => '2019-01-09 12:11', 'context' => '仓库-已签收'],
                   ['time' => '2019-01-07 12:11', 'context' => '广东XX服务点'],
                   ['time' => '2019-01-06 12:11', 'context' => '广东XX转运中心']
               ],
               'logistics_company' => '申通快递',
               'logistics_bill_no' => '12312211'
           ]
       ]
   ]
]

百度接口获取物流信息

$logistics->query('12313131231', 'baidu');
$logistics->query('12313131231', ['baidu']);

示例:

[
   'baidu' => [
       'channel' => 'baidu',
       "status" => 'success',
       'result' => [
           [
               'status' => 200,
               'message'  => 'OK',
               'error_code' => 0,
               'data' => [
                   ['time' => '1545444420', 'desc' => '仓库-已签收'],
                   ['time' => '1545441977', 'desc' => '广东XX服务点'],
                   ['time' => '1545438199', 'desc' => '广东XX转运中心']
               ],
               'logistics_company' => '申通快递',
               'logistics_bill_no' => '12312211'
           ]
       ]
   ]
]

多接口获取物流信息

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

示例:

[
   'kuaidi100' => [
       'channel' => 'kuaidi100',
       "status" => 'success',
       'result' => [
           [
               'status' => 200,
               'message'  => 'OK',
               'error_code' => 0,
               'data' => [
                   ['time' => '2019-01-09 12:11', 'context' => '仓库-已签收'],
                   ['time' => '2019-01-07 12:11', 'context' => '广东XX服务点'],
                   ['time' => '2019-01-06 12:11', 'context' => '广东XX转运中心']
               ],
               'logistics_company' => '申通快递',
               'logistics_bill_no' => '12312211'
           ]
       ]
   ]
]

参数说明

array query(string $code, $channels = ['kuaidi100'])
  • $code - 运单号
  • $channel - 渠道名称, 可选参数,默认快递100.目前支持百度(baidu), 快递100(kuaidi100), 爱查快递(ickd)

有关请求次数

据测试随机生成100个运单循环请求, 目前没有限制. 但这些接口都是我抓包得来, 虽然我随机设置user-agent, 但是不够保险, 因此可能请求过多会有限制,就要更换IP来去请求.

参考

最后

感谢安正超 - 超哥提供教程, 让我知道如何构建一个包, 学习到很多东西. 其实我才做PHP没多久, 没想到有这么多人star. 虽然现在才121,但对我来说是一份认可, 谢谢.

欢迎提出issue和pull request

License

MIT

logistics's People

Contributors

almas1992 avatar samnela avatar uuk020 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.