顺丰快递单号查询(顺丰快递单号查询跟踪)
如何利用快递鸟提供的接口来查询顺丰快递的物流轨迹。
我们先来看一下,接口完成以后的实际显示效果
以下是产品应用截图,
实际上快递鸟返回的报文信息会更详细,在给客户展示的信息可根据产品需要来封装返回轨迹信息。
现在我们来聊一聊实现方式!
首先我们准备好需要用到的资源,测试商户ID:
test1617571
测试API key:
554343b2-7252-439b-b4eb-1af42c8f2175(此Key仅限测试环境使用)
API测试地址:
http://
sandboxapi.kdniao.com:8080
/kdniaosandbox/gateway/exterfaceInvoke.json
接口参数,也叫业务参数,请求的业务接口不同,参数的字段,内容也不同,是跟着业务变化的,这里我们实现的是即时查询接口,请求指令类型:1002,快递鸟官网要求必须传递快递公司编码和物流单号 ,顺丰快递的编码是SF
这里需要注意,查询顺丰快递单号,需要添加一个应用级参数CustomerName,并且是必填
我们用顺丰单号295734066970来实现轨迹查询,
顺丰快递请求JSON
{
‘OrderCode’: ”,
‘ShipperCode’: ‘SF’,
‘LogisticCode’: ‘295734066970’,
‘CustomerName’: ‘6073’
}
请求的完整报文(URL编码以后):
RequestData=%0d%0a++++++++++++%7b%27OrderCode%27%3a%27%27%2c%27ShipperCode%27%3a%27SF%27%2c%27LogisticCode%27%3a%27295734066970%27%2c%27CustomerName%27%3a%276073%27%7d%0d%0a++++++++&EBusinessID=1264783&RequestType=1002&DataSign=ZTJlZWU0NjI1YTljNTlmYzY5Y2M4YjMzYjcxYWU3MDA%3d&DataType=2
未编码的请求报文:
RequestData={‘OrderCode’:”,’ShipperCode’:’SF’,’LogisticCode’:’295734066970′,’CustomerName’:’6073′}&EBusinessID=1264783&RequestType=1002&DataSign=ZTJlZWU0NjI1YTljNTlmYzY5Y2M4YjMzYjcxYWU3MDA=&DataType=2
返回参数定义:
顺丰单号295734066970的返回报文信息
{ "LogisticCode": "295734066970", "ShipperCode": "SF", "Traces": [{ "AcceptStation": "顺丰速运 已收取快件", "AcceptTime": "2020-02-13 18:39:21" }, { "AcceptStation": "快件在【衡水桃城区集收客户营业部】已装车,准备发往 【石家庄高开集散中心】", "AcceptTime": "2020-02-13 18:39:31" }, { "AcceptStation": "快件已发车", "AcceptTime": "2020-02-13 19:15:24" }, { "AcceptStation": "快件到达 【石家庄高开集散中心】", "AcceptTime": "2020-02-14 04:27:00" }, { "AcceptStation": "快件在【石家庄高开集散中心】已装车,准备发往 【长沙星沙集散中心】", "AcceptTime": "2020-02-14 08:36:14" }, { "AcceptStation": "快件已发车", "AcceptTime": "2020-02-14 18:34:31" }, { "AcceptStation": "快件到达 【长沙星沙集散中心】", "AcceptTime": "2020-02-16 09:58:05" }, { "AcceptStation": "快件在【长沙星沙集散中心】已装车,准备发往 【怀化盈口集散点】", "AcceptTime": "2020-02-16 11:03:53" }, { "AcceptStation": "快件已发车", "AcceptTime": "2020-02-16 11:50:35" }, { "AcceptStation": "快件到达 【怀化盈口集散点】", "AcceptTime": "2020-02-16 20:20:42" }, { "AcceptStation": "快件在【怀化盈口集散点】已装车,准备发往 【沅陵县御鑫城营业点】", "AcceptTime": "2020-02-17 05:33:23" }, { "AcceptStation": "快件已发车", "AcceptTime": "2020-02-17 05:33:37" }, { "AcceptStation": "快件到达 【沅陵县御鑫城营业点】", "AcceptTime": "2020-02-17 07:55:20" }, { "AcceptStation": "快件在【沅陵县御鑫城营业点】已装车,准备发往 【怀化市沅陵县二酉苗族乡合作点】", "AcceptTime": "2020-02-17 09:31:53" }, { "AcceptStation": "快件到达 【怀化市沅陵县二酉苗族乡合作点】", "AcceptTime": "2020-02-17 09:32:16" }, { "AcceptStation": "正在派送途中,请您准备签收(派件人:邓小云,电话:13298660182)", "AcceptTime": "2020-02-17 09:32:31" }, { "AcceptStation": "快件交给邓小云,正在派送途中(联系电话:13298660182,顺丰已开启“安全呼叫”保护您的电话隐私,请放心接听!)", "AcceptTime": "2020-02-17 09:33:26" }, { "AcceptStation": "已签收,感谢使用顺丰,期待再次为您服务(主单总件数:1件)", "AcceptTime": "2020-02-17 22:41:24" }, { "AcceptStation": "在官网\"运单资料&签收图\",可查看签收人信息", "AcceptTime": "2020-02-17 22:41:26" }], "State": "3", "EBusinessID": "1264783", "Success": true } 没有物流轨迹,会返回如下报文: { "LogisticCode": "295734066970", "ShipperCode": "SF", "Traces": [], "State": "0", "EBusinessID": "1264783", "Reason": "暂无轨迹信息", "Success": true } 未实名认证,未订购套餐或者套餐可用查询量已经用完返回如下报文: { "LogisticCode": "295734066970", "ShipperCode": "SF", "Traces": [], "State": "0", "EBusinessID": "1264783", "Reason": "业务错误[没有可用套餐]", "Success": false }