PHP code example of bolechen / zto-php-sdk

1. Go to this page and download the library: Download bolechen/zto-php-sdk 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/ */

    

bolechen / zto-php-sdk example snippets



$zto = new \Bolechen\Zto\Zto([
    // 官网获取的 合作商编码(company_id)
    'apiCompanyId' => '',
    'apiKey' => '',

    'debug' => true, // 调试模式
    'sandbox' => false, // 沙盒模式

    'log' => [
        'name' => 'zto',
        'file' => __DIR__.'/zto.log',
        'level' => 'debug',
        'permission' => 0777,
    ]
]);

// 查询最后一条物流信息
$params['data'] = '["680000000000","680000000001"]';
$result = $zto->trace->traceInterfaceNewTraces($params);

// 获取指定的省市区
$params['data'] = '310000';
$result = $zto->base->baseAreaGetArea($params);

// 电子面单余额查询
$params['data'] = '{"partner": "ZTO_1001149603"}';
$result = $zto->bill->partnerInsertAvailablecounter($params);
shell
$ composer