In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to call the third-party express logistics order number to query api in Java, I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Comparison of third Party Logistics Interface
There are two types of express query API: instant query and subscription query. Data is returned immediately upon request, subscription is to subscribe to the express order number to the API, and full data is returned if the logistics track is updated. At present, the commonly used are express bird, express 100, aggregate data, Aliyun logistics and so on.
Express bird instant API can query 3000 times, more than 3000 can be connected to the subscription interface, unified interface mode access, commonly used express delivery support query, as well as subscription API, online order API, electronic single API, the interface is free of charge, users are not required to add outside the chain, support 418 domestic and foreign express logistics query.
Express 100 can be queried 2000 times a day for free, with a charge of more than 2000 times, ranging from 0.06 to 0.1 yuan each time. If the number of queries is large, the fee can be reduced. Several common express delivery companies do not support the interface mode, but only support htmlAPI. Users are required to add external chains and support more than 300 domestic and foreign express logistics queries.
Because the company uses express bird products, so here finally chose the express bird logistics API.
API description:
Java interfacing: `package com.zs.app
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.security.MessageDigest; import java.util.HashMap; import java.util.Map
/ *
Instant query Interface for Express Bird Logistics track
@ Technical QQ group: 456320272
@ see: http://www.kdniao.com/YundanChaxunAPI.aspx
@ copyright: Shenzhen Kuaijin data Technology Service Co., Ltd.
E-commerce ID and private key in DEMO can only be used for testing. Please register your account separately in the formal environment.
If the number of queries exceeds 500 per day, it is recommended to connect to our logistics track subscription and push interface.
For ID and Key, please apply on the official website: http://www.kdniao.com/ServiceApply.aspx * /
Public class KdniaoTrackQueryAPI {
/ / DEMOpublic static void main (String [] args) {KdniaoTrackQueryAPI api = new KdniaoTrackQueryAPI (); try {String result = api.getOrderTracesByJson ("ANE", "210001633605"); System.out.print (result);} catch (Exception e) {e.printStackTrace ();}} / / E-commerce IDprivate String EBusinessID= "1330422" / / encrypted private key for e-commerce, provided by express bird, be careful to keep it, do not disclose private String AppKey= "7611818b-6279-4398-8747-df2ca39e86b4"; / / request urlprivate String ReqURL= "http://api.kdniao.cc/Ebusiness/EbusinessOrderHandle.aspx";" / * Json query order logistics track * [@ throws] (https://my.oschina.net/throws) Exception * / public String getOrderTracesByJson (String expCode, String expNo) throws Exception {String requestData= "{'OrderCode':'','ShipperCode':'" + expCode + "', 'LogisticCode':'" + expNo + "'}"; Map params = new HashMap (); params.put ("RequestData", urlEncoder (requestData, "UTF-8")) Params.put ("EBusinessID", EBusinessID); params.put ("RequestType", "1002"); String dataSign=encrypt (requestData, AppKey, "UTF-8"); params.put ("DataSign", urlEncoder (dataSign, "UTF-8"); params.put ("DataType", "2"); String result=sendPost (ReqURL, params); / / the information returned according to the company's business processing. Return result;} / * MD5 encryption * [@ param] (https://my.oschina.net/u/2303379) 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 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) > > 2]); sb.append (base64EncodeChars [(b1 & 0x03) > 4)]); sb.append (base64EncodeChars [(b2 & 0x0f) > > 2]); sb.append (base64EncodeChars [(b1 & 0x03) > > 4)]; sb.append (base64EncodeChars [(b2 & 0x0f) > > 6)]) Sb.append (Base64EncodeCharts [b3 & 0x3f]);} return sb.toString ();}
} `
After reading the above, have you mastered the method of how to call the third-party express logistics order number to query api in Java? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.