在现代商业中,供应链的协同运作至关重要。
快递物流查询API接口可以实现供应商、电商平台、物流企业和消费者之间的信息无缝对接,各方能够及时获取快递物流信息,从而更好地协调生产、销售和配送等环节,提高整个供应链的效率和效益,减少库存积压和缺货现象。
快递物流查询API接口具有良好的兼容性和可集成性,能够轻松地与电商平台、仓储管理系统、客户关系管理系统等各类企业应用系统进行集成,实现信息的互联互通,打造一体化的企业管理解决方案。
以下是用PHP调用快递物流查询API接口的代码示例:
<?php$appKey = "您的appKey";
$appSecret= "您的appSecret";$url = "https://api.shuxuntech.com/v1/express/query";
$method = "POST";$timestamp = getUnixTimestamp();
var_dump($timestamp);
$sign = hash('sha256',$appKey . $timestamp . $appSecret);
var_dump($sign);$headers = array();
array_push($headers, "Content-Type" . ":" . "application/x-www-form-urlencoded; charset=UTF-8");
array_push($headers, "appKey" . ":" . appKey);
array_push($headers, "timestamp" . ":" . timestamp);
array_push($headers, "sign" . ":" . sign);$no = "";
$code = "";
$tel = "";
$bodys = "no=" . $no . "&code=" . $code . "&tel=" . $tel;$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);if (1 == strpos("$".$url, "https://")) {curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
var_dump(curl_exec($curl));function getUnixTimestamp () {list($s1, $s2) = explode(' ', microtime());return sprintf('%.0f',(floatval($s1) + floatval($s2)) * 1000);
}
返回的数据:
(1)正确返回
{"code": "0","msg": "成功","isFee": 1,"seqNo": "8bdguy0kbojrkq9cf5tp3l4tidbpile3","data": {"theLastTime": "2024-02-28 13:47:43", //运单号物流流转当前最新描述"cpCode": "EMS", //快递公司编码"mailNo": "9858345266141", //快递单号"cpMobile": "11183", //快递公司电话"theLastMessage": "您的快件已签收【南阳理工学院软件学院东菜鸟驿站】,如有疑问请电联快递员【电话:15737715502】。连接美好,无处不在,感谢您使用中国邮政,期待再次为您服务。",//运单号物流流转当前最新描述"logisticsCompanyName": "EMS", //快递公司名称"cpUrl": "https://www.ems.com.cn/", //快递公司官网"takeTime": "2天3小时50分", //从揽收到送达所耗时间"logisticsStatusDesc": "已签收", //运单号当前物流状态文字描述"logisticsTraceDetailList": [ //物流流转明细{"areaCode": "CN411300000000", //非必须,当前节点所在地址行政编码"areaName": "河南省,南阳市", //非必须,当前节点所在地区,省,市,区或省,市"subLogisticsStatus": "SIGN", //物流流转子状态,详见:物流状态编码对照表"time": 1709099263000, //时间,单位毫秒"logisticsStatus": "SIGN", //物流流转状态,详见:物流状态编码对照表"desc": "您的快件已签收【南阳理工学院软件学院东菜鸟驿站】,如有疑问请电联快递员【电话:15737715502】。连接美好,无处不在,感谢您使用中国邮政,期待再次为您服务。"//物流流转描述},{"areaCode": "CN411300000000","areaName": "河南省,南阳市","subLogisticsStatus": "STA_INBOUND","time": 1709098104000,"logisticsStatus": "DELIVERING","desc": "您的快件已派送至【南阳理工学院软件学院东菜鸟驿站】,自提点电话:15303770902,请您凭取件码领取快件,如有疑问请电联快递员【电话:15737715502】,投诉请致电11183。"},{"areaCode": "CN411300000000","areaName": "河南省,南阳市","subLogisticsStatus": "DELIVERING","time": 1709084792000,"logisticsStatus": "DELIVERING","desc": "快件正在派送中,请耐心等待,保持电话畅通,准备签收,如有疑问请电联快递员【苗莹莹,电话:15737715502】或揽投部【电话:0377-63116200】,投诉请致电11183。"},{"areaCode": "CN411300000000","areaName": "河南省,南阳市","subLogisticsStatus": "TRANSPORT","time": 1709084492000,"logisticsStatus": "TRANSPORT","desc": "快件到达【南阳市白河揽投部】"},{"areaCode": "CN411300000000","areaName": "河南省,南阳市","subLogisticsStatus": "TRANSPORT","time": 1709074003000,"logisticsStatus": "TRANSPORT","desc": "快件离开【南阳市包件车间】,正在发往下一站"},{"areaCode": "CN411300000000","areaName": "河南省,南阳市","subLogisticsStatus": "TRANSPORT","time": 1709058177000,"logisticsStatus": "TRANSPORT","desc": "快件到达【南阳市包件车间】"},{"areaCode": "CN411700000000","areaName": "河南省,驻马店市","subLogisticsStatus": "TRANSPORT","time": 1709036234000,"logisticsStatus": "TRANSPORT","desc": "快件离开【驻马店市包件车间】,正在发往下一站"},{"areaCode": "CN411700000000","areaName": "河南省,驻马店市","subLogisticsStatus": "TRANSPORT","time": 1709032670000,"logisticsStatus": "TRANSPORT","desc": "快件到达【驻马店市包件车间】"},{"areaCode": "CN510100000000","areaName": "四川省,成都市","subLogisticsStatus": "TRANSPORT","time": 1708962186000,"logisticsStatus": "TRANSPORT","desc": "快件离开【成都双流处理中心天府包件车间】,正在发往下一站"},{"areaCode": "CN510100000000","areaName": "四川省,成都市","subLogisticsStatus": "TRANSPORT","time": 1708952075000,"logisticsStatus": "TRANSPORT","desc": "快件到达【成都双流处理中心天府包件车间】"},{"areaName": "四川省,成都市,新津县","subLogisticsStatus": "TRANSPORT","time": 1708952067000,"logisticsStatus": "TRANSPORT","desc": "快件离开【新津区电商客户平岗路揽投部】,正在发往【成都双流处理中心天府包件车间】"},{"areaName": "四川省,成都市,新津县","subLogisticsStatus": "TRANSPORT","time": 1708952066000,"logisticsStatus": "TRANSPORT","desc": "快件已在【新津区电商客户平岗路揽投部】完成分拣,准备发出"},{"areaCode": "CN510100000000","areaName": "四川省,成都市","subLogisticsStatus": "ACCEPT","time": 1708911453000,"logisticsStatus": "ACCEPT","desc": "中国邮政 已收取快件"}],"logisticsStatus": "SIGN" //物流流转状态,详见:物流状态编码对照表;}
}
(2)错误返回
{"code": "1","msg": "请输入快递编号","isFee": 0,"seqNo": null,"data": null
}
不过需要注意的是,实际应用中你需要先获取合法的 API 密钥等相关配置信息,并根据具体使用的 API 提供商的文档来准确实现完整功能。