在使用之前,您需要先去trackmore官方网站申请API_KEY,传送门:TrackMore
html
代码语言:javascript复制<script type="text/javascript" src="/plugins/TrackMore/trackmore.js"></script>
<a href="javascript:;" onclick="trackmore.query('运单号','快递名称')">TrackMore</a>
<!--
快递名称参见cfg.php,用于映射快递公司代码
-->
<div id="queryContext" class="flo" style="display: none;"></div>
<div id="queryContextbg" style="display: none;"></div>
trackmore.js
代码语言:javascript复制var trackmore = {
init:function(){
/*加载样式表*/
var url='/plugins/TrackMore/skin/style.css?' new Date().getTime();
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = url;
document.getElementsByTagName("head")[0].appendChild(link);
var csstype = "flo";
/*
fix 固定 flo 浮动
默认浮动,不需要在页面添加容器
使用固定的方式在页面容器中指定class="fix"
*/
var cont = $("#queryContext");
if(cont.length<1){
$(document.body).append('<div id="queryContext" class="' csstype '"></div>');
cont = $("#queryContext");
}
if($("#queryContextbg").length<1){
$(document.body).append('<div id="queryContextbg"></div>');
}
cont.hide();
$("#queryContextbg").hide();
},
query:function(codenum,codename){
var cont=$("#queryContext");
if(cont.length<1)
{
$(document.body).append('<div id="queryContext"></div>');
cont=$("#queryContext");
}
if(codenum.length<1 || codename.length<1){
shtml='快递单号或者物流类型为空';
retrun;
}
Ajax.call('/plugins/TrackMore/trackmore_post.php','num=' codenum '&com=' codename,function(result){
if(result.meta.code == 200){
var status;
var origin_info = result.data.items[0].origin_info;
var shtml = '<div class="header">';
shtml = '<div class="th">';
shtml = '<h2>物流轨迹</h2>';
shtml = '<span>' codename ':' codenum '</span>';
shtml = '<a class="close" href="#" onclick="kdniao.close()"></a>';
shtml = '</div>';
shtml = '</div>';
shtml = '<div class="tbody">';
shtml = '<table class="kd_tb"><thead><tr><th class="th" colspan="4"></th></tr></thead><tbody>';
for(i=0;i<origin_info.trackinfo.length;i ){
switch(i){
case origin_info.trackinfo.length-1:
status = "fir";
break;
case 0:
status = "end";
break;
default:
status = "mid";
break;
}
var sigleinfo = origin_info.trackinfo[i]
sigleinfo_date = sigleinfo.Date.split(" ");
shtml = '<tr><td class="td1"><b class="' status '"></b></td><td>' sigleinfo_date[0] '</td><td>' sigleinfo_date[1] '</td><td>' sigleinfo.Details '</td><td>' sigleinfo.StatusDescription '</td>';
}
shtml = '</tbody></table>';
shtml = '</div>';
shtml = '<div class="footer"><div class="info">以上信息由物流公司提供,如无跟踪信息或有疑问,请咨询对应的物流公司</div></div>';
cont.html(shtml).show();
}
} , 'POST', 'JSON')
},
close:function(){
$("#queryContext").hide();
$("#queryContextbg").hide();
}
}
trackmore.init();
trackmore_cfg.php
代码语言:javascript复制<?php
header("content-type:text/html;charset=utf-8");
switch ($getcom){
case "韵达速递":
$postcom = "yunda";
break;
case "中通快递":
$postcom = "zto";
break;
case "申通快递":
$postcom = "sto";
break;
case "圆通快递":
$postcom = "yto";
break;
case "顺丰速递":
$postcom = "sf-express";
break;
case "EMS":
$postcom = "china-ems";
break;
case "天天快递":
$postcom = "ttkd";
break;
default:
$postcom = "";
break;
}
?>
trackmore_post.php
代码语言:javascript复制<?php
header("content-type:text/html;charset=utf-8");
$getcom = trim($_POST["com"]);
$getnum = trim($_POST["num"]);
include_once('trackmore_cfg.php');
include_once("track.class.php");
/*
* 这里是正式生产环境下使用的内容
$track = new Trackingmore;
$extraInfo['lang'] = 'cn';
$track = $track -> getRealtimeTrackingResults($postcom,$getnum,$extraInfo);
$return_json = json_encode($track);
*/
/*
* 这里是模拟trackmore返回数据
*/
$return_json = include('test_result.php');
echo $return_json;
?>
track.class.php
代码语言:javascript复制<?php
class Trackingmore{
const API_BASE_URL = 'http://api.trackingmore.com/v2/';
const ROUTE_CARRIERS = 'carriers/';//获取运输商简码
const ROUTE_CARRIERS_DETECT = 'carriers/detect';//通过跟踪代码检测载波
const ROUTE_TRACKINGS = 'trackings';//接口主路径
const ROUTE_LIST_ALL_TRACKINGS = 'trackings/get';//获取多个运单号的物流信息
const ROUTE_CREATE_TRACKING = 'trackings/post';//创建单个运单号
const ROUTE_TRACKINGS_BATCH = 'trackings/batch'; //创建多个运单号
const ROUTE_TRACKINGS_REALTIME = 'trackings/realtime';//获取单个运单号实时物流信息
const ROUTE_TRACKINGS_RELETE = 'trackings/delete';//删除多个运单号
const ROUTE_TRACKINGS_UPDATE = 'trackings/update';//修改运输商简码
const ROUTE_TRACKINGS_GETUSEINFO = 'trackings/getuserinfo';//查询用户剩余额度
const ROUTE_TRACKINGS_GETSTATUS = 'trackings/getstatusnumber';//查看不同状态快递数量
const ROUTE_TRACKINGS_NOTUPDATE = 'trackings/notupdate';//设置部分单号不再更新
const ROUTE_TRACKINGS_REMOTE = 'trackings/remote';//查询收货地址是否偏远
const ROUTE_TRACKINGS_COSTTIME = 'trackings/costtime';//获取成本时间迭代结果
const ROUTE_TRACKINGS_UPDATEMORE = 'trackings/updatemore';//修改多个运单号附加信息。如:订单号,商品标题,快递状态等。
protected $apiKey = 'your api_key';//API Key
protected function _getApiData($route, $method = 'GET', $sendData = array()){
$method = strtoupper($method);
$requestUrl = self::API_BASE_URL.$route;
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL,$requestUrl);
if($method == 'GET'){
curl_setopt($curlObj, CURLOPT_HTTPGET,true);
}elseif($method == 'POST'){
curl_setopt($curlObj, CURLOPT_POST, true);
}elseif ($method == 'PUT'){
curl_setopt($curlObj, CURLOPT_CUSTOMREQUEST, "PUT");
}else{
curl_setopt($curlObj, CURLOPT_CUSTOMREQUEST, $method);
}
curl_setopt($curlObj, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curlObj, CURLOPT_TIMEOUT, 90);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
$headers = array(
'Trackingmore-Api-Key: ' . $this->apiKey,
'Content-Type: application/json',
);
if($sendData){
$dataString = json_encode($sendData);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $dataString);
$headers[] = 'Content-Length: ' . strlen($dataString);
}
curl_setopt($curlObj, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curlObj);
curl_close($curlObj);
unset($curlObj);
return $response;
}
// List all carriers
public function getCarrierList(){
$returnData = array();
$requestUrl = self::ROUTE_CARRIERS;
$result = $this->_getApiData($requestUrl, 'GET');
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/*Detect a carrier by tracking code
* @param string $trackingNumber Tracking number
* @return array
*/
public function detectCarrier($trackingNumber)
{
$returnData = array();
$requestUrl = self::ROUTE_CARRIERS_DETECT;
$sendData['tracking_number'] = $trackingNumber;
$result = $this->_getApiData($requestUrl, 'POST',$sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* List all trackings
* @access public
* @param int $numbers Tracking numbers,eg:$numbers = LY044217709CN,UG561422482CN (optional)
* @param int $orders Tracking order,eg:$orders = #123 (optional)
* @param int $page Page to display (optional)
* @param int $limit Items per page (optional)
* @param int $createdAtMin Start date and time of trackings created (optional)
* @param int $createdAtMax End date and time of trackings created (optional)
* @param int $update_time_min Start date and time of trackings updated (optional)
* @param int $update_time_max End date and time of trackings updated (optional)
* @param int $order_created_time_min Start date and time of order created (optional)
* @param int $order_created_time_max End date and time of order created (optional)
* @param int $lang Language,eg:$lang=cn(optional)
* @return array
*/
public function getTrackingsList($numbers = "",$orders = "",$page = 1,$limit = 100,$createdAtMin = 0,$createdAtMax = 0,$update_time_min = 0,$update_time_max = 0,$order_created_time_min = 0,$order_created_time_max = 0,$lang = "en"){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_LIST_ALL_TRACKINGS;
$createdAtMax = !empty($createdAtMax)?$createdAtMax:time();
$update_time_max = !empty($update_time_max)?$update_time_max:time();
$order_created_time_max = !empty($order_created_time_max)?$order_created_time_max:time();
$sendData['page'] = $page;
$sendData['limit'] = $limit;
$sendData['created_at_min'] = $createdAtMin;
$sendData['created_at_max'] = $createdAtMax;
$sendData['update_time_min'] = $update_time_min;
$sendData['update_time_max'] = $update_time_max;
$sendData['order_created_time_min'] = $order_created_time_min;
$sendData['order_created_time_max'] = $order_created_time_max;
$sendData['lang'] = $lang;
$sendData['numbers'] = $numbers;
$sendData['orders'] = $orders;
$result = $this->_getApiData($requestUrl, 'GET', $sendData);
if ($result) {
$returnData = json_decode($result);
}
return $returnData;
}
/**
* Create a tracking item
* @access public
* @param string $trackingNumber Tracking number
* @param string $carrierCode Carrier code
* @param array $extraInfo (Title,Customer name,email,order ID,customer phone,order create time,destination code,tracking ship date,tracking postal code,language) (optional)
* @return array
*/
public function createTracking($carrierCode,$trackingNumber,$extraInfo = array()){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_CREATE_TRACKING;
$sendData['tracking_number'] = $trackingNumber;
$sendData['carrier_code'] = $carrierCode;
$sendData['title'] = !empty($extraInfo['title'])?$extraInfo['title']:null;
$sendData['logistics_channel'] = !empty($extraInfo['logistics_channel'])?$extraInfo['logistics_channel']:null;
$sendData['customer_name'] = !empty($extraInfo['customer_name'])?$extraInfo['customer_name']:null;
$sendData['customer_email'] = !empty($extraInfo['customer_email'])?$extraInfo['customer_email']:null;
$sendData['order_id'] = !empty($extraInfo['order_id'])?$extraInfo['order_id']:null;
$sendData['customer_phone'] = !empty($extraInfo['customer_phone'])?$extraInfo['customer_phone']:null;
$sendData['order_create_time'] = !empty($extraInfo['order_create_time'])?$extraInfo['order_create_time']:null;
$sendData['destination_code'] = !empty($extraInfo['destination_code'])?$extraInfo['destination_code']:'';
$sendData['tracking_ship_date'] = !empty($extraInfo['tracking_ship_date'])?$extraInfo['tracking_ship_date']:null;
$sendData['tracking_postal_code'] = !empty($extraInfo['tracking_postal_code'])?$extraInfo['tracking_postal_code']:"";
$sendData['lang'] = !empty($extraInfo['lang'])?$extraInfo['lang']:"en";
$result = $this->_getApiData($requestUrl, 'POST', $sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* Create multiple trackings.
* @access public
* @param array $multipleData (Multiple tracking number,carrier code,title,customer name,customer email,order id,destination code,customer phone,order create time,tracking ship date,tracking postal code,special number destination,language)
* @return array
*/
public function createMultipleTracking($multipleData){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_TRACKINGS_BATCH;
if(!empty($multipleData)){
foreach($multipleData as $val){
$items = array();
$items['tracking_number'] = !empty($val['tracking_number'])?$val['tracking_number']:null;
$items['carrier_code'] = !empty($val['carrier_code'])?$val['carrier_code']:null;
$items['title'] = !empty($val['title'])?$val['title']:null;
$items['logistics_channel'] = !empty($val['logistics_channel'])?$val['logistics_channel']:null;
$items['customer_name'] = !empty($val['customer_name'])?$val['customer_name']:null;
$items['customer_email'] = !empty($val['customer_email'])?$val['customer_email']:null;
$items['order_id'] = !empty($val['order_id'])?$val['order_id']:null;
$items['destination_code'] = !empty($val['destination_code'])?$val['destination_code']:null;
$items['customer_phone'] = !empty($val['customer_phone'])?$val['customer_phone']:null;
$items['order_create_time'] = !empty($val['order_create_time'])?$val['order_create_time']:null;
$items['tracking_ship_date'] = !empty($val['tracking_ship_date'])?$val['tracking_ship_date']:null;
$items['tracking_postal_code'] = !empty($val['tracking_postal_code'])?$val['tracking_postal_code']:null;
$items['specialNumberDestination'] = !empty($val['specialNumberDestination'])?$val['specialNumberDestination']:null;
$items['lang'] = !empty($val['lang'])?$val['lang']:'en';
$sendData[] = $items;
}
}
$result = $this->_getApiData($requestUrl, 'POST', $sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* Get tracking results of a single tracking
* @access public
* @param string $trackingNumber Tracking number
* @param string $carrierCode Carrier code
* @param string $lang language
* @return array
*/
public function getSingleTrackingResult($carrierCode,$trackingNumber,$lang='en'){
$returnData = array();
$requestUrl = self::ROUTE_TRACKINGS.'/'.$carrierCode.'/'.$trackingNumber.'/'.$lang;
$result = $this->_getApiData($requestUrl, 'GET');
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* Update Tracking item
* @access public
* @param string $trackingNumber Tracking number
* @param string $carrierCode Carrier code
* @param array $extraInfo (Title,Customer name,email,order ID,customer phone,destination code,status) (optional)
* @return array
*/
public function updateTrackingItem($carrierCode,$trackingNumber,$extraInfo){
$returnData = array();
$requestUrl = self::ROUTE_TRACKINGS.'/'.$carrierCode.'/'.$trackingNumber;
$sendData['title'] = !empty($extraInfo['title'])?$extraInfo['title']:null;
$sendData['logistics_channel'] = !empty($extraInfo['logistics_channel'])?$extraInfo['logistics_channel']:null;
$sendData['customer_name'] = !empty($extraInfo['customer_name'])?$extraInfo['customer_name']:null;
$sendData['customer_email'] = !empty($extraInfo['customer_email'])?$extraInfo['customer_email']:null;
$sendData['customer_phone'] = !empty($extraInfo['customer_phone'])?$extraInfo['customer_phone']:null;
$sendData['order_id'] = !empty($extraInfo['order_id'])?$extraInfo['order_id']:null;
$sendData['destination_code']= !empty($extraInfo['destination_code'])?$extraInfo['destination_code']:null;
$sendData['status']= !empty($extraInfo['status'])?$extraInfo['status']:null;
$result = $this->_getApiData($requestUrl, 'PUT',$sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* Delete a tracking item
* @access public
* @param string $trackingNumber Tracking number
* @param string $carrierCode Carrier code
* @return array
*/
public function deleteTrackingItem($carrierCode,$trackingNumber){
$returnData = array();
$requestUrl = self::ROUTE_TRACKINGS.'/'.$carrierCode.'/'.$trackingNumber;
$result = $this->_getApiData($requestUrl, 'DELETE');
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* Get realtime tracking results of a single tracking
* @access public
* @param string $trackingNumber Tracking number
* @param string $carrierCode Carrier code
* @param array $extraInfo (Destination_code,Tracking_ship_date Customer_email,Tracking_postal_code,SpecialNumberDestination,order,lang) (optional)
* @return array
*/
public function getRealtimeTrackingResults($carrierCode,$trackingNumber,$extraInfo=array()){
$returnData = array();
$requestUrl = self::ROUTE_TRACKINGS_REALTIME;
$sendData['tracking_number'] = $trackingNumber;
$sendData['carrier_code'] = $carrierCode;
$sendData['destination_code'] = !empty($extraInfo['destination_code'])?$extraInfo['destination_code']:null;
$sendData['tracking_ship_date'] = !empty($extraInfo['tracking_ship_date'])?$extraInfo['tracking_ship_date']:null;
$sendData['order_create_time'] = !empty($extraInfo['order_create_time'])?$extraInfo['order_create_time']:null;
$sendData['tracking_postal_code'] = !empty($extraInfo['tracking_postal_code'])?$extraInfo['tracking_postal_code']:null;
$sendData['specialNumberDestination'] = !empty($extraInfo['specialNumberDestination'])?$extraInfo['specialNumberDestination']:null;
$sendData['order'] = !empty($extraInfo['order'])?$extraInfo['order']:null;
$sendData['lang'] = !empty($extraInfo['lang'])?$extraInfo['lang']:null;
$result = $this->_getApiData($requestUrl, 'POST',$sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* delete multiple tracking
* @access public
* @param array $multipleData (tracking number,carrier code)
* @return array
*/
public function deleteMultipleTracking($multipleData){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_TRACKINGS_RELETE;
if(!empty($multipleData)){
foreach ($multipleData as $val){
$items = array();
$items['tracking_number'] = !empty($val['tracking_number'])?$val['tracking_number']:null;
$items['carrier_code'] = !empty($val['carrier_code'])?$val['carrier_code']:null;
$sendData[] = $items;
}
}
$result = $this->_getApiData($requestUrl, 'POST', $sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* update carrier code
* @access public
* @param string $trackingNumber Tracking number
* @param string $carrierCode Carrier code
* @param string $carrierCode Update carrier code
* @return array
*/
public function updateCarrierCode($tracking_number,$carrier_code,$update_carrier_code){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_TRACKINGS_UPDATE;
$sendData["tracking_number"] = $tracking_number;
$sendData["carrier_code"] = $carrier_code;
$sendData["update_carrier_code"] = $update_carrier_code;
$result = $this->_getApiData($requestUrl, 'POST', $sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* update carrier code
* @access public
* @return array
*/
public function getUserInfoBalance(){
$returnData = array();
$requestUrl = self::ROUTE_TRACKINGS_GETUSEINFO;
$result = $this->_getApiData($requestUrl, 'GET');
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* update carrier code
* @access public
* @param int $created_at_min Start date and time of trackings created (optional)
* @param int $created_at_max End date and time of trackings created (optional)
* @param int $order_created_time_min Start date and time of order created (optional)
* @param int $order_created_time_max End date and time of order created (optional)
* @return array
*/
public function getStatusNumberCount($created_at_min = 0,$created_at_max = 0,$order_created_time_min = 0,$order_created_time_max = 0){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_TRACKINGS_GETSTATUS;
$sendData["created_at_min"] = !empty($created_at_min)?$created_at_min:null;
$sendData["created_at_max"] = !empty($created_at_max)?$created_at_max:time();
$sendData["order_created_time_min"] = !empty($order_created_time_min)?$order_created_time_min:null;
$sendData["order_created_time_max"] = !empty($order_created_time_max)?$order_created_time_max:time();
$result = $this->_getApiData($requestUrl, 'GET',$sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* update carrier code
* @access public
* @param array $multipleData (tracking number,carrier code)
* @param string $carrierCode Carrier code
* @return array
*/
public function setNumberNotUpdate($multipleData){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_TRACKINGS_NOTUPDATE;
if(!empty($multipleData)){
foreach ($multipleData as $val){
$items = array();
$items['tracking_number'] = !empty($val['tracking_number'])?$val['tracking_number']:null;
$items['carrier_code'] = !empty($val['carrier_code'])?$val['carrier_code']:null;
$sendData[] = $items;
}
}
$result = $this->_getApiData($requestUrl, 'POST',$sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* update carrier code
* @access public
* @param array $multipleData (Country two code,Post code or city name,company),eg:array(0=>array("CN","518131","DHL"));
* @return array
*/
public function searchDeliveryIsRemote($multipleData){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_TRACKINGS_REMOTE;
if(!empty($multipleData)){
foreach ($multipleData as $val){
$items = array();
$items['country'] = !empty($val['country'])?$val['country']:null;
$items['postcode'] = !empty($val['postcode'])?$val['postcode']:null;
$items['company'] = !empty($val['company'])?$val['company']:null;
$sendData[] = $items;
}
}
$result = $this->_getApiData($requestUrl, 'POST',$sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* update carrier code
* @access public
* @param array $multipleData (Country two code,Post code or city name,company),eg:array(0=>array("CN","518131","DHL"));
* @return array
*/
public function getCarrierCostTime($multipleData){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_TRACKINGS_COSTTIME;
if(!empty($multipleData)){
foreach ($multipleData as $val){
$items = array();
$items['carrier_code'] = !empty($val['carrier_code'])?$val['carrier_code']:null;
$items['original'] = !empty($val['original'])?$val['original']:null;
$items['destination'] = !empty($val['destination'])?$val['destination']:null;
$sendData[] = $items;
}
}
$result = $this->_getApiData($requestUrl, 'POST',$sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
/**
* update carrier code
* @access public
* @param array $multipleData (Country two code,Post code or city name,company),eg:array(0=>array("CN","518131","DHL"));
* @return array
*/
public function updateMultipleTrackItem($multipleData){
$returnData = array();
$sendData = array();
$requestUrl = self::ROUTE_TRACKINGS_UPDATEMORE;
if(!empty($multipleData)){
foreach ($multipleData as $val){
$items = array();
$items['tracking_number'] = !empty($val['tracking_number'])?$val['tracking_number']:null;
$items['carrier_code'] = !empty($val['carrier_code'])?$val['carrier_code']:null;
$items['title'] = !empty($val['title'])?$val['title']:null;
$items['logistics_channel'] = !empty($val['logistics_channel'])?$val['logistics_channel']:null;
$items['customer_name'] = !empty($val['customer_name'])?$val['customer_name']:null;
$items['customer_email'] = !empty($val['customer_email'])?$val['customer_email']:null;
$items['order_id'] = !empty($val['order_id'])?$val['order_id']:null;
$items['destination_code'] = !empty($val['destination_code'])?$val['destination_code']:null;
$items['status'] = !empty($val['status'])?$val['status']:null;
$sendData[] = $items;
}
}
$result = $this->_getApiData($requestUrl, 'POST',$sendData);
if ($result) {
$returnData = json_decode($result, true);
}
return $returnData;
}
}
?>
test_result.php,由于测试账号每20分钟仅可请求一次,我在这里将首次请求返回结果放在这个文件,模拟trackmore的返回数据
代码语言:javascript复制<?php
return "{
"meta" : {
"code" : 200,
"type" : "Success",
"message" : "Success"
},
"data" : {
"items" : [{
"id" : "ef7b311fc15c7c1f58523a5076d8ad6f",
"tracking_number" : "3814040916275",
"carrier_code" : "yunda",
"order_create_time" : "",
"destination_code" : "",
"status" : "delivered",
"original_country" : "",
"itemTimeLength" : 3,
"stayTimeLength" : 112,
"service_code" : null,
"substatus" : null,
"last_mile_tracking_supported" : null,
"origin_info" : {
"ItemReceived" : "2018-02-03 21:51:25",
"ItemDispatched" : null,
"DepartfromAirport" : null,
"ArrivalfromAbroad" : null,
"CustomsClearance" : null,
"DestinationArrived" : null,
"weblink" : "http://yundaex.com/cn/index.php",
"phone" : null,
"carrier_code" : "yunda",
"trackinfo" : [{
"Date" : "2018-02-06 19:49:26",
"StatusDescription" : "快件已被 已签收 签收",
"Details" : "广东湛江公司北月便民寄存点分部",
"checkpoint_status" : "delivered"
},{
"Date" : "2018-02-06 12:04:47",
"StatusDescription" : "进行派件扫描;派送业务员:陈汉淇;联系电话:13078298668",
"Details" : "广东湛江公司北月便民寄存点分部",
"checkpoint_status" : "transit"
},{
"Date" : "2018-02-05 20:36:15",
"StatusDescription" : "进行快件扫描,将发往:广东湛江公司北月便民寄存点分部",
"Details" : "广东湛江公司",
"checkpoint_status" : "transit"
},{
"Date" : "2018-02-05 00:20:55",
"StatusDescription" : "从站点发出,本次转运目的地:广东湛江公司",
"Details" : "广东中山分拨中心",
"checkpoint_status" : "transit"
},{
"Date" : "2018-02-05 00:13:30",
"StatusDescription" : "在分拨中心进行卸车扫描",
"Details" : "广东中山分拨中心",
"checkpoint_status" : "transit"
},{
"Date" : "2018-02-04 05:07:20",
"StatusDescription" : "进行装车扫描,即将发往:广东中山分拨中心",
"Details" : "广东揭阳分拨中心",
"checkpoint_status" : "transit"
},{
"Date" : "2018-02-04 05:04:51",
"StatusDescription" : "在分拨中心进行称重扫描",
"Details" : "广东揭阳分拨中心",
"checkpoint_status" : "transit"
},{
"Date" : "2018-02-03 22:02:41",
"StatusDescription" : "进行下级地点扫描,将发往:广东湛江公司",
"Details" : "广东普宁南公司",
"checkpoint_status" : "transit"
},{
"Date" : "2018-02-03 21:51:25",
"StatusDescription" : "进行揽件扫描",
"Details" : "广东普宁南公司",
"checkpoint_status" : "transit"
}]
},
"destination_info" : null,
"lastEvent" : "快件已被 已签收 签收,广东湛江公司北月便民寄存点分部,2018-02-06 19:49:26",
"lastUpdateTime" : "2018-02-06 19:49:26"
}]
}
}";
?>
点击下方图片前往:TrackMore官网
下载除html以外的其他部分:download_trackmore
本文采用 「CC BY-NC-SA 4.0」创作共享协议,转载请标注以下信息:
原文出处:Yiiven https://cloud.tencent.com/developer/article/2193111