Bird Express Logistics single query API interface integration, there is a need to use direct online

Bird Express is the world's largest third-party logistics Express interface services provider, we have integrated 418 express a single query interface, 31 electronic side single interface. High real-time, high stability, high concurrency, support express a single number for automatic identification.

Express courier third party Bird query interface very easy to use, many users (there are more than a dozen thousand technology QQ group), large ERP basically using a courier birds interfaces, non-scouring system of electronic business platform are also Interface with the service provided by the courier birds. Whole butt is very simple, the application for registration and ID KEY free to express Birds website, download call demo, after docking at the parameters modify it. There is free version and the paid version targeted, according to their need to select the appropriate service plan 

Official Website:  http://www.kdniao.com

Instant Lookup API:  http://www.kdniao.com/api-track

Need to log in to apply for what user ID and API key

Request demo Case: Bird Express official website has a variety of demo languages ​​to choose from, for example with java

Example Request:

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 com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
import java.security.MessageDigest; 

// electricity supplier ID 
    Private String EBusinessID = " 1.2371 million " ;    
     // electricity providers private key encryption, providing courier birds, take good care, do not leak (to be re-application ID) 
    Private String AppKey = " 518a73d8-1f7f-441a-b644-33e77b49d846 " ;    
     // request URL 
    Private String reqURL = " http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx " ;     
 
    / * * 
     * Json embodiment subscription information stream 
     * @throws Exception 
     * / 
    public String orderTracesSubByJson () throws Exception { 
        String requestData = "{'Code': 'SF','Item': ["+
                           "{'No': '909261024507','Bk': 'test'},"+
                           "{'No': '589554393102','Bk': 'test'},"+
                           "{'No': '589522101958','Bk': 'test'},"+
                           "{'No': '909198822942', 'Bk': 'test'}"+
                           "]}";
        
        Map<String, String> params = new HashMap<String, String>();
        params.put("RequestData", urlEncoder(requestData, "UTF-8"));
        params.put("EBusinessID", EBusinessID);
        params.put("RequestType", "1005");
        String dataSign=encrypt(requestData, AppKey, "UTF-8");
        params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
        params.put("DataType" , " 2 " ); 
        
        String the Result = sendPost (reqURL, params );     
        
        // According to the information of the company's business processing returns ...... 
        
        return the Result; 
    } 
    
    / * * 
     * XML Subscribe way logistics information 
     * @throws Exception 
     * / 
    public String orderTracesSubByXml () throws Exception { 
        String requestData = " <? XML Version = \" 1.0 \ "encoding = \" UTF-. 8 \ "?> " +
                             " <the Content> " +
                             " <Code> SF </ Code >"+
                            "<Items>"+
                            "<Item>"+
                            "<No>909261024507</No>"+
                            "<Bk>test</Bk>"+
                            "</Item>"+
                            "<Item>"+
                            "<No>909261024507</No>"+
                            "<Bk>test</Bk>"+
                            "</Item>"+
                            "</Items>"+
                            "</Content>";
        
        Map<String, String> params = new HashMap<String, String>();
        params.put("RequestData", urlEncoder(requestData, "UTF-8"));
        params.put("EBusinessID", EBusinessID);
        params.put("RequestType", "1005");
        DataSign String = the encrypt (requestData, the AppKey, " UTF-. 8 " );
         the params .put ( " DataSign " , URLEncoder (dataSign, " UTF-. 8 " ));
         the params .put ( " the DataType " , " . 1 " ); 
        
        String Result = sendPost (reqURL, the params );     
        
        // the information returned from the business processing ...... 
        
        return Result; 
    } 
        
    / * * 
     * the MD5 encrypted 
     * @param str content         
     * @param charset encoding
     * @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 = Base64.encode(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")
    privateString the encrypt (String Content, String the keyValue, String charset) throws UnsupportedEncodingException, Exception 
    { 
        IF (the keyValue =! Null ) 
        { 
            return Base64 (the MD5 (Content + the keyValue, charset), charset); 
        } 
        return Base64 (the MD5 (Content, charset) , charset); 
    } 
    
     / * * 
     * sends a POST request method specified URL      
     * URL @param url transmission request     
     * @param params request parameter set      
     * @return remote resources in response to the results 
     * / 
    @SuppressWarnings ( " unused " )
     Private String sendPost (String url, the Map <String, String>the params ) { 
        the OutputStreamWriter OUT = null ; 
        the BufferedReader in = null ;         
        the StringBuilder Result = new new the StringBuilder (); 
         the try { 
            the URL realUrl = new new the URL (URL); 
            the HttpURLConnection Conn = (the HttpURLConnection) realUrl.openConnection ();
             // send a POST request must provided the following two lines 
            conn.setDoOutput ( to true ); 
            conn.setDoInput ( to true );
             // the POST method
            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" , " File application / X-WWW-form-urlencoded " ); 
            conn.connect (); 
            // Get URLConnection object corresponding to the output stream 
            OUT = new new the OutputStreamWriter (conn.getOutputStream (), " UTF-. 8 " );
             // transmission request parameter             
            IF ( the params =! null ) { 
                  the StringBuilder param = new new the StringBuilder (); 
                   for (of Map.Entry <String, String> entry: the 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 ()); 
            } 
            // the flush buffered output stream 
            OUT .flush ();
             // define BufferedReader input stream to read the URL of the response 
            in = new new BufferedReader (
                     new new the InputStreamReader (conn.getInputStream () , " UTF-. 8 " )); 
            String Line; 
            the while ((= Line in .readline ()) =! null ) { 
                result.append (Line); 
            } 
        } the catch (Exception E) {             
            e.printStackTrace (); 
        } 
        //Use finally block to close the output stream, the input stream 
        finally {
             the try {
                 IF ( OUT =! Null ) {
                     OUT .close (); 
                } 
                IF ( in =! Null ) {
                     in .close (); 
                } 
            } 
            the catch (IOException EX) { 
                ex.printStackTrace (); 
            } 
        } 
        return result.toString (); 
    } 
}

Guess you like

Origin www.cnblogs.com/kdn2019/p/12113062.html