PHP code example of careywong / logistics

1. Go to this page and download the library: Download careywong/logistics library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

careywong / logistics example snippets


use CareyWong\Logistics\Logistics;
$logistics = new Logistics();

$service = $logistics->getInstance('KDNiao');
$service->setConfig($EBusinessID, $AppKey);

# 获取快递单所属快递公司信息
$service->getShipper($trackingNumber);

# 获取快递轨迹
$service->getTrace($shipmentId, $trackingNumber);

use CareyWong\Logistics\Logistics;
$logistics = new Logistics();

$service = $logistics->getInstance('Trackingmore');
$service->setConfig($ApiKey);

# 获取快递单所属快递公司信息
$service->getShipper($trackingNumber);

# 获取快递轨迹
$service->getTrace($shipmentId, $trackingNumber);

$formatTrace = [
    'success' => '',
    'message' => '',
    'trackingNumber' => '123456789',
    'trackinfo' => [ // 按时间顺序排序
            0 => [
              "time" => "2018-06-30 00:46:30",
              "event" => " XXX 已揽收",
            ],
            1 => [
              "time" => "2018-06-30 03:41:06",
              "event" => "已发往 XXX ",
            ],
            ...
            6 => [
                  "time" => "2018-07-01 18:26:59",
                  "event" => " XXX 已签收",
            ],
    ],
    'lastEvent' => ' XXX 已签收',
    'lastUpdateTime' => '2018-07-01 18:26:59',
    'packageStatus' => '2', // 0: 无轨迹,1:在途,2:已签收,3:异常
];