Free logistics and express a single query interface to quickly guide the docking

[Scene demand Description

Electronic business platform and ISV business demand for logistics api interface, there are many, and today we share is the main docking guide birds express courier single query interface number, express a single query interface docking scenarios are many, many scenes encounter, the most important is called when the user opens the electricity supplier website "my orders" this API to display details of logistics information, the electricity supplier logistics system management background, the status of all customer service inquiries sign the waybill before reconciliation, and tracing, electronic business platform to-business logistics management and control requirements must embrace the pieces must be sent to see how long the express condition, to see how long the goods receipt must be received by the state, according to the state of the business management and control to improve overall user satisfaction. The figure is the electronic business platform, buyers, orders shipped flowchart businesses.

Free logistics and express a single query interface to quickly guide the docking
[Butt] using flow

1, a single number and transmits express courier companies to express coding Bird

2, express logistics birds query to track state based on a single number and courier companies

3, the bird will express logistics queries to track back to the state electricity provider platform for service providers or ISV

4, electronic business platform ISV ​​or service provider receives the data and do real-time processing or data presentation applications

Free logistics and express a single query interface to quickly guide the docking

Interface Description [description]

(1) query interface support in accordance with Tracking Number (single query).
(2) express a single number to specify the interface of Express encoding format will not return an error or failure information is encoded.
Such as: EMS single stream number should be selected coding Express (EMS) Express view coding
(3) tracking information returned stream are arranged in ascending order of time occurrence.
(4) 1002 interface commands.
(5) the interface to support message receiving mode HTTP POST, the request method of encoding format (utf-8): "application / x-www-form-urlencoded; charset = utf-8".
(6) Test Address: http://sandboxapi.kdniao.com:8080/kdniaosandbox/gateway/exterfaceInvoke.json ...
(7) Official address: http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx . ..

System Level Request Parameters:
Free logistics and express a single query interface to quickly guide the docking

NOTE: R- required (Required), O- optional (Optional), C- packets are optional under certain conditions (the Conditional)

[Interface Parameters

Requesting the content field definition:

Return parameter definitions:

[Example]


请求示例 JSON

{
                "OrderCode": "",
                "ShipperCode": "SF",
                "LogisticCode": "118650888018"
                }

Returning to the example JSON

No trace of logistics

   {
        "EBusinessID": "1109259",
        "Traces": [],
        "OrderCode": "",
        "ShipperCode": "SF",
        "LogisticCode": "118461988807",
        "Success": false,
        "Reason": null
        }
        有物流轨迹的
        {
        "EBusinessID": "1109259",
        "OrderCode": "",
        "ShipperCode": "SF",
        "LogisticCode": "118461988807",
        "Success": true,
        "State": 3,
        "Reason": null,
        "Traces": [
        {
        "AcceptTime": "2014/06/25 08:05:37",
        "AcceptStation": "正在派件..(派件人:邓裕富,电话:18718866310)[深圳 市]",
        "Remark": null
        },
        {
        "AcceptTime": "2014/06/25 04:01:28",
        "AcceptStation": "快件在 深圳集散中心 ,准备送往下一站 深圳 [深圳市]",
        "Remark": null
        },
        {
        "AcceptTime": "2014/06/25 01:41:06",
        "AcceptStation": "快件在 深圳集散中心 [深圳市]",
        "Remark": null
        },
        {
        "AcceptTime": "2014/06/24 20:18:58",
        "AcceptStation": "已收件[深圳市]",
        "Remark": null
        },
        {
        "AcceptTime": "2014/06/24 20:55:28",
        "AcceptStation": "快件在 深圳 ,准备送往下一站 深圳集散中心 [深圳市]",
        "Remark": null
        },
        {
        "AcceptTime": "2014/06/25 10:23:03",
        "AcceptStation": "派件已签收[深圳市]",
        "Remark": null
        },
        {
        "AcceptTime": "2014/06/25 10:23:03",
        "AcceptStation": "签收人是:已签收[深圳市]",
        "Remark": null
        }
        ]
        }

[JAVA express a single query interface Demo example], other birds Demo to express official website to download

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.security.MessageDigest;

/*

public class KdniaoSubscribeAPI {

//DEMO
public static void main(String[] args) {
    KdniaoSubscribeAPI api = new KdniaoSubscribeAPI();
    try {
        String result = api.orderTracesSubByJson();
        System.out.print(result);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

//电商ID
private String EBusinessID="请到快递鸟官网申请http://www.kdniao.com/ServiceApply.aspx";
//电商加密私钥,快递鸟提供,注意保管,不要泄漏
private String AppKey="请到快递鸟官网申请http://www.kdniao.com/ServiceApply.aspx";
//测试请求url
private String ReqURL = "http://testapi.kdniao.com:8081/api/dist";
//正式请求url
//private String ReqURL = "http://api.kdniao.com/api/dist";

/**
 * Json方式  物流信息订阅
 * @throws Exception 
 */
public String orderTracesSubByJson() throws Exception{
    String requestData="{'OrderCode': 'SF201608081055208281'," +
                            "'ShipperCode':'SF'," +
                            "'LogisticCode':'3100707578976'," +
                            "'PayType':1," +
                            "'ExpType':1," +
                            "'CustomerName':'',"+
                            "'CustomerPwd':''," +
                            "'MonthCode':''," +
                            "'IsNotice':0," +
                            "'Cost':1.0," +
                            "'OtherCost':1.0," +
                            "'Sender':" +
                            "{" +
                            "'Company':'LV','Name':'Taylor','Mobile':'15018442396','ProvinceName':'上海','CityName':'上海','ExpAreaName':'青浦区','Address':'明珠路73号'}," +
                            "'Receiver':" +
                            "{" +
                            "'Company':'GCCUI','Name':'Yann','Mobile':'15018442396','ProvinceName':'北京','CityName':'北京','ExpAreaName':'朝阳区','Address':'三里屯街道雅秀大厦'}," +
                            "'Commodity':" +
                            "[{" +
                            "'GoodsName':'鞋子','Goodsquantity':1,'GoodsWeight':1.0}]," +
                            "'Weight':1.0," +
                            "'Quantity':1," +
                            "'Volume':0.0," +
                            "'Remark':'小心轻放'}";

    Map<String, String> params = new HashMap<String, String>();
    params.put("RequestData", urlEncoder(requestData, "UTF-8"));
    params.put("EBusinessID", EBusinessID);
    params.put("RequestType", "1008");
    String dataSign=encrypt(requestData, AppKey, "UTF-8");
    params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
    params.put("DataType", "2");

    String result=sendPost(ReqURL, params); 

    //根据公司业务处理返回的信息......

    return result;
}

/**
 * MD5加密
 * @param str 内容       
 * @param charset 编码方式
 * @throws Exception 
 */
@SuppressWarnings("unused")
private String MD5(String str, String charset) throws Exception {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(str.getBytes(charset));
    byte[] result = md.digest();
    StringBuffer sb = new StringBuffer(32);
    for (int i = 0; i < result.length; i++) {
        int val = result[i] & 0xff;
        if (val <= 0xf) {
            sb.append("0");
        }
        sb.append(Integer.toHexString(val));
    }
    return sb.toString().toLowerCase();
}

/**
 * base64编码
 * @param str 内容       
 * @param charset 编码方式
 * @throws UnsupportedEncodingException 
 */
private String base64(String str, String charset) throws UnsupportedEncodingException{
    String encoded = base64Encode(str.getBytes(charset));
    return encoded;    
}   

@SuppressWarnings("unused")
private String urlEncoder(String str, String charset) throws UnsupportedEncodingException{
    String result = URLEncoder.encode(str, charset);
    return result;
}

/**
 * 电商Sign签名生成
 * @param content 内容   
 * @param keyValue Appkey  
 * @param charset 编码方式
 * @throws UnsupportedEncodingException ,Exception
 * @return DataSign签名
 */
@SuppressWarnings("unused")
private String encrypt (String content, String keyValue, String charset) throws UnsupportedEncodingException, Exception
{
    if (keyValue != null)
    {
        return base64(MD5(content + keyValue, charset), charset);
    }
    return base64(MD5(content, charset), charset);
}

 /**
 * 向指定 URL 发送POST方法的请求     
 * @param url 发送请求的 URL    
 * @param params 请求的参数集合     
 * @return 远程资源的响应结果
 */
@SuppressWarnings("unused")
private String sendPost(String url, Map<String, String> params) {
    OutputStreamWriter out = null;
    BufferedReader in = null;        
    StringBuilder result = new StringBuilder(); 
    try {
        URL realUrl = new URL(url);
        HttpURLConnection conn =(HttpURLConnection) realUrl.openConnection();
        // 发送POST请求必须设置如下两行
        conn.setDoOutput(true);
        conn.setDoInput(true);
        // POST方法
        conn.setRequestMethod("POST");
        // 设置通用的请求属性
        conn.setRequestProperty("accept", "*/*");
        conn.setRequestProperty("connection", "Keep-Alive");
        conn.setRequestProperty("user-agent",
                "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.connect();
        // 获取URLConnection对象对应的输出流
        out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
        // 发送请求参数            
        if (params != null) {
              StringBuilder param = new StringBuilder(); 
              for (Map.Entry<String, String> entry : params.entrySet()) {
                  if(param.length()>0){
                      param.append("&");
                  }               
                  param.append(entry.getKey());
                  param.append("=");
                  param.append(entry.getValue());                     
                  System.out.println(entry.getKey()+":"+entry.getValue());
              }
              System.out.println("param:"+param.toString());
              out.write(param.toString());
        }
        // flush输出流的缓冲
        out.flush();
        // 定义BufferedReader输入流来读取URL的响应
        in = new BufferedReader(
                new InputStreamReader(conn.getInputStream(), "UTF-8"));
        String line;
        while ((line = in.readLine()) != null) {
            result.append(line);
        }
    } catch (Exception e) {            
        e.printStackTrace();
    }
    //使用finally块来关闭输出流、输入流
    finally{
        try{
            if(out!=null){
                out.close();
            }
            if(in!=null){
                in.close();
            }
        }
        catch(IOException ex){
            ex.printStackTrace();
        }
    }
    return result.toString();
}

private static char[] base64EncodeChars = new char[] { 
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 
        'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 
        'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 
        'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 
        'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 
        'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 
        'w', 'x', 'y', 'z', '0', '1', '2', '3', 
        '4', '5', '6', '7', '8', '9', '+', '/' }; 

public static String base64Encode(byte[] data) { 
    StringBuffer sb = new StringBuffer(); 
    int len = data.length; 
    int i = 0; 
    int b1, b2, b3; 
    while (i < len) { 
        b1 = data[i++] & 0xff; 
        if (i == len) 
        { 
            sb.append(base64EncodeChars[b1 >>> 2]); 
            sb.append(base64EncodeChars[(b1 & 0x3) << 4]); 
            sb.append("=="); 
            break; 
        } 
        b2 = data[i++] & 0xff; 
        if (i == len) 
        { 
            sb.append(base64EncodeChars[b1 >>> 2]); 
            sb.append(base64EncodeChars[((b1 & 0x03) << 4) | ((b2 & 0xf0) >>> 4)]); 
            sb.append(base64EncodeChars[(b2 & 0x0f) << 2]); 
            sb.append("="); 
            break; 
        } 
        b3 = data[i++] & 0xff; 
        sb.append(base64EncodeChars[b1 >>> 2]); 
        sb.append(base64EncodeChars[((b1 & 0x03) << 4) | ((b2 & 0xf0) >>> 4)]); 
        sb.append(base64EncodeChars[((b2 & 0x0f) << 2) | ((b3 & 0xc0) >>> 6)]); 
        sb.append(base64EncodeChars[b3 & 0x3f]); 
    } 
    return sb.toString(); 
}

}

【NET版本demo使用示例】

1、可以按照自己需求新建一个页面,进行传参和展示数据。


2、调用demo中的方法返回结果,对返回结果进行显示处理。


3、将demo中如图所示替换


4、对下图方法中的入参进行处理,result即为返回值。


5、下图即为按照上述方法处理后的效果图。

【接入流程】

快递鸟单号自动识别接口(API)接入视频教程

快递鸟单号查询接口(API)接入视频教程​​​​​​​

  1. 登录快递鸟官网注册页面注册快递鸟账号
  2. 登录快递鸟用户管理后台

注:登录快递鸟用户管理后台后获得用户ID和APIKey对应各demo中的EBusinessID、AppKey。

小知识:EBusinessID跟APIKey是什么?EBusinessID跟APIKey您在快递鸟网站注册之后快递鸟分配的密钥(对应官网上的用户ID和API key),用于保证应用来源的可靠性,避免应用伪造,被不法使用。

3.进入“我的会员中心”进行实名认证

3.1、认证类型、应用类型根据用户实际情况选择即可,接口返回数据与选择结果无关;

3.2、标记为*的为必填,要求上传清晰、jpg格式且小于2M的证件图片;

3.3、技术对接人信息为用户方对接工程师的信息;

3.4、如有其他疑问可进入快递鸟官网加入右侧的QQ群进行咨询。

4.认证成功后,进入“产品服务管理”,开通相关会员服务

4.1、物流查询(免费版)会员套餐为免费版,有效期1年结束后,如在近3个月内有数据交互系统会自动免费续期;

4.2、如有其他疑问可进入官网加入商务合作群(群号:616310430)进行咨询。

5.开发对接

5.1、即时查询(RequestType:1002/8001)日查询次数<=3000次对接即时查询接口

5.1.1、请求接口之前需要先实名认证,开通相关会员服务,否则会请求失败并返回提示“未申请开通接口”;

5.1.2、接口开发可以下载“快递鸟接口技术文档”进行参考;即时查询,参考技术文档中的4.1或5.1.1部分;

5.1.3、接口开发可以下载“即时查询demo”进行参考(仅提供了.NET、Java、PHP三种语言demo);

5.1.4、查看快递公司对应快递鸟的编码可以下载“2018快递鸟接口支持快递公司编码列表.xlsx”。

5.1.5、接入过程中如有疑问请先参考快递鸟官网常见问题进行解决,也可以进入快递鸟官网加入技术对接群进行咨询。

5.2、物流跟踪(RequestType:1008/8008)日查询次数>3000次对接物流跟踪接口

5.2.1、请求接口之前需要先实名认证,开通相关会员服务,否则会请求失败并返回提示“未申请开通接口”;

5.2.2、接口开发需下载“快递鸟接口技术文档”进行查看;物流跟踪,参考技术文档中的4.2或5.1.2部分;

5.2.3、开发订阅接口:

5.2.3.1、可以下载“物流跟踪demo”进行参考(仅提供了.NET、Java、PHP三种语言的demo),

其他语言开发的用户需要根据技术文档自行开发;

5.2.3.2、测试订阅接口,对照技术文档正确返回代表订阅接口对接成功,详情可见技术文档。

5.2.4、开发推送接口:

5.2.4.1、无demo提供,推送时会推送requestType、requestData和DataSign三个参数,您开发一个推送接口接收这三个参数就行,成功接收后需要在5S内给快递鸟返回成

功收数据的报文,否则超时。RequestData中包含应用级参数,即物流轨迹(详情看技术文档);

5.2.4.2、在沙箱调试平台(沙箱调试平台地址:http://kdniao.com/UserCenter/v2/SandBox/PushQueryParam.aspx...)配置回调地址,测试推送接口。回调地址是用户提供

用于接收快递鸟推送的物流信息的,只要是外网可以访问的就行。测试、配置步骤如下:

a、填写回调地址:

b、点击【生成】后 应用级参数报文(RequestData)就是推送到用户第一步时填写的回调地址上的测试物流信息。

c、点击【调用】,用户接收到测试的物流信息后,用户需要在 应用级参数报文区域 返回成功接收的信号给快递鸟(注:字段间不要存在空格,空格会影响返回结果),

返回格式:{"EBusinessID":"1237100","UpdateTime":"2015-03-11 16:26:11","Success":true,"Reason": ""}

d、调用结果显示为请求成功后即用户开发的推送接口通过测试。

e、测试通过后回到第一步填写回调地址的位置点击【配置】,弹出弹框,填写手机号(必须是注册快递鸟账号的手机号)、验证码、

回调地址,点击【保存】配置成功即可在正式环境使用,下次如果需要修改回调地址同初次配置回调地址步骤一致。

​5.2.5、订阅接口、推送接口分别测试成功后,可使用正式地址进行订阅真实的快递单号,快递鸟一般会在2-12小时内推送物流信息至您已经配置好的回调地址上;

5.2.6、接口开发查看快递公司对应快递鸟的编码可以下载“2019快递鸟接口支持快递公司编码列表.xlsx”;

5.2.7、接入过程中如有疑问请先参考快递鸟官网常见问题进行解决,也可以进入快递鸟官网加入技术对接群进行咨询。

【你可能还关心的问题】

1、问题:快递鸟接口有并发要求吗?

快递鸟即时查询接口并发不超过10次/秒,物流跟踪接口订阅不超过30次/秒,电子面单接口下单不超过20次/秒。

2、问题:快递鸟api收费标准是什么?

快递鸟查询接口和电子面单等接口都是免费提供的,如果您对数据的状态时效、服务等有特别的需求,可联系快递鸟工作人员,为您量身定制专属解决方案,具体收费会根据您的需求进行商定。

3、问题:快递鸟数据更新实时性如何?

即时查询接口:实时获取当前最新轨迹信息,数据与官网信息一致。

物流跟踪接口:快递鸟每2小时到快递公司获取轨迹,如果您订阅的单号没有轨迹更新,间隔2小时后再次到快递公司获取轨迹,依次循环直到有物流轨迹更新,获取到新轨迹后进行排队序列推送。

4、问题:快递鸟数据准确性,会不会存在物流状态不准确的问题?

轨迹信息准确度大于99.9%。物流轨迹信息保持与快递公司官网一致,偶尔存在快递公司提供的接口数据与官网不一致的情况,不一致情况小于0.1%。

5、问题:快递鸟即时查询接口和物流跟踪接口有什么区别?

(1)接入方式不一样:

即时查询接口,根据快递单号和快递公司编码实时查询物流轨迹信息。

物流跟踪接口,用户订阅快递号,快递鸟系统会定时推送新的物流信息。

(2)实现的功能不一样:

即时查询接口,单次请求只能查询一个单的物流信息,支持10次/S的并发请求。

物流跟踪接口,订阅推送的模式获取轨迹信息,发起一次订阅后,快递鸟会持续监控推送更新的轨迹信息,直到签收。

(3)查询单量不一样:

即时查询每日查询次数<=3000次,物流跟踪不限制订阅单量,并可一直获得每个单号的更新信息。

6、问题: 快递鸟物流跟踪数据的时效性怎样?

在接收到新的快递单后,会立即加入监控队列,有结果的话会即时内返回,没有结果的话,会等待一定时间(如2小时)再进行下一次监控。对于这些后续的监控,如果某运单号在快递公司官网对应的结果B,B最新一条状态所对应的时间为T1,快递鸟将B推送给贵公司的时间为T2,那么|T2-T1|一般在0~2~4 个小时以内,但我方会不断地向贵方进行推送,使运单状态能持续地更新。

7、问题:快递鸟物流跟踪是需要我们自己开发接收接口是吗?

对接物流跟踪接口,你需要开发订阅接口(将单号和快递公司编码订阅给快递鸟。有订阅接口的.net,php和java版本demo,你可以参考下。还有自己开发一个推送接口(接收快递鸟推送的物流轨迹),开发完后登录快递鸟沙箱后台调试推送接口,调试成功后可在沙箱后台自助配置推送接口。

8、问题:快递鸟物流跟踪的推送接口怎么做?

Push the interface is used to receive push logistics information, push the interface we call your interface, you only need to receive parameters, configure your callback address in the sandbox back on the line, RequestData contains application-level parameters, stream track, when push will push requestType, requestData and DataSign three parameters (details see technical documentation), you develop a push interface to receive these three parameters on the line.

9, question: Bird express logistics tracking API to achieve what is the principle?

Subscribe to the interface works: users will subscribe to express a single number to us, we immediately went to join the queue logistics company official interface to query, there are tracks give users push. If the data will go two hours without re-updated logistics company official query interfaces, new data will be pushed to the user the full amount of data, if the data is not updated two hours and then repeat the action until the receipt of the consignment.

10, question: Bird express courier logistics company which supports query interface?

Bird express express logistics company to support 418 interfaces, in particular birds courier official website to download "2019 Bird Express interface support Express coding .xlsx" view.

Guess you like

Origin blog.51cto.com/14466758/2423295