After the interface of reservation and pick-up is connected, the online express delivery function can be realized in the website system, Courier bird The reservation pick-up interface also supports the domestic mainstream express delivery, so there is no need to connect one by one. The implementation style is as shown in the figure:
Interface specification
(1) Reservation pick-up interface is a single interface provided by express bird to Independent E-commerce, storage management system, logistics supply chain and other logistics system platforms.
(2) To solve the online delivery demand for customers, the merchant selects the express company through the network to send a request to inform the express company that there is express delivery to deliver.
(3) The customer forwards the data to the express bird through this interface, and the express bird arranges the courier to pick up the goods at home.
(4) Order code cannot be submitted repeatedly, and the system will return specific error code.
(5) The message receiving method supported by the interface is HTTP POST, and the encoding format of the request method (utf-8): "application/x-www-form-urlencoded;charset=utf-8".
(6) Interface address: API test address: http://testapi.kdniao.cc:8081/api/OOrderService
API official address: http://api.kdniao.cc/api/OOrderService
Interface parameters
Docking demo
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; /** * * Express bird online order interface * * @Technical QQ: 4009633321 * @Technical QQ group: 200121393 * @see: http://www.kdniao.com/api-order * @copyright: Shenzhen kuaijin Data Technology Service Co., Ltd * * ID And Key, please go to the official website to apply: http://www.kdniao.com/ServiceApply.aspx */ public class KdGoldAPIDemo { //Electricity supplier ID private String EBusinessID="Please go to express bird website to apply http://www.kdniao.com/ServiceApply.aspx"; //E-commerce encrypts the private key, which is provided by express bird. Take care not to disclose private String AppKey="Please go to express bird website to apply http://www.kdniao.com/ServiceApply.aspx"; //Test request url private string ReqURL = "http://testapi.kdniao.cc:8081/api/oorderservice"; //Official request url //private string ReqURL = "http://api.kdniao.cc/api/OOrderService"; /** * Json Online order * @throws Exception */ public String orderOnlineByJson() throws Exception{ String requestData= "{'OrderCode': '012657700312'," + "'ShipperCode':'YTO'," + "'PayType':1," + "'ExpType':1," + "'Cost':1.0," + "'OtherCost':1.0," + "'Sender':" + "{" + "'Company':'LV','Name':'Taylor','Mobile':'15018442396','ProvinceName':'Shanghai','CityName':'Shanghai','ExpAreaName':'Qingpu District','Address':'73 Mingzhu Road'}," + "'Receiver':" + "{" + "'Company':'GCCUI','Name':'Yann','Mobile':'15018442396','ProvinceName':'Beijing','CityName':'Beijing','ExpAreaName':'Chaoyang District','Address':'Yaxiu building, Sanlitun Street'}," + "'Commodity':" + "[{" + "'GoodsName':'shoes','Goodsquantity':1,'GoodsWeight':1.0}]," + "'AddService':" + "[{" + "'Name':'COD','Value':'1020'}]," + "'Weight':1.0," + "'Quantity':1," + "'Volume':0.0," + "'Remark':'Handle with care'," + "'Commodity':" + "[{" + "'GoodsName':'shoes'," + "'Goodsquantity':1," + "'GoodsWeight':1.0}]" + "}"; Map<String, String> params = new HashMap<String, String>(); params.put("RequestData", urlEncoder(requestData, "UTF-8")); params.put("EBusinessID", EBusinessID); params.put("RequestType", "1001"); String dataSign=encrypt(requestData, AppKey, "UTF-8"); params.put("DataSign", urlEncoder(dataSign, "UTF-8")); params.put("DataType", "2"); String result=sendPost(ReqURL, params); //Information returned according to the company's business processing return result; } /** * MD5 encryption * @param str content * @param charset Coding mode * @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 Code * @param str content * @param charset Coding mode * @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; } /** * E-commerce Sign generation * @param content content * @param keyValue Appkey * @param charset Coding mode * @throws UnsupportedEncodingException ,Exception * @return DataSign autograph */ @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); } /** * Send a request for the POST method to the specified URL * @param url URL to send the request * @param params Parameter set requested * @return Response results for remote resources */ @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(); // To send a POST request, you must set the following two lines conn.setDoOutput(true); conn.setDoInput(true); // POST method conn.setRequestMethod("POST"); // Set common request properties 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(); // Get the output stream corresponding to URLConnection object out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8"); // Send request parameters 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()); } // Buffer of flush output stream out.flush(); // Define BufferedReader input stream to read response of 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(); } //Use finally block to close output flow and input flow finally{ try{ if(out!=null){ out.close(); } if(in!=null){ in.close(); } } catch(IOException ex){ ex.printStackTrace(); } } return result.toString(); } }