|
|
|
|
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
curl http://cloud.kuaidi100.com/api -X POST -d \ "secret_key=***&secret_code=81bb0620fbaf460db4e6dab84a05ec00&secret_sign=md5(***)&from=&to=&com=&orderTime="
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net. HttpURLConnection; import java.net. URL; import java.net. URLEncoder; import java.security. MessageDigest; import java.security. NoSuchAlgorithmException; import java.util. HashMap; import java.util. Map; public class CloudDemo { public static void main (String[] args) { CloudDemo cloudDemo = new CloudDemo(); Map params = new HashMap (); params.put("secret_key", "***"); params.put("secret_code", "81bb0620fbaf460db4e6dab84a05ec00"); params.put("secret_sign", "md5(***)"); params.put("from", ""); params.put("to", ""); params.put("com", ""); params.put("orderTime", ""); cloudDemo.post(params); } public String post(Map params) { StringBuilder response = new StringBuilder(""); BufferedReader reader = null; try { StringBuilder builder = new StringBuilder(); for (Map.Entry param : params.entrySet()) { if (builder.length() > 0) { builder.append('&'); } builder.append(URLEncoder.encode(param.getKey(), "UTF-8")); builder.append('='); builder.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8")); } byte[] bytes = builder.toString().getBytes("UTF-8"); URL url = new URL(" http://cloud.kuaidi100.com/api "); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(5000); conn.setReadTimeout(5000); conn.setRequestMethod("POST"); conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); conn.setRequestProperty("Content-Length", String.valueOf(bytes.length)); conn.setDoOutput(true); conn.getOutputStream().write(bytes); reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8")); String line = ""; while ((line = reader.readLine()) != null) { response.append(line); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (null != reader) { reader.close(); } } catch (IOException e) { e.printStackTrace(); } } return response.toString(); } } class MD5Utils { private static MessageDigest mdigest = null; private static char digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; private static MessageDigest getMdInst() { if (null == mdigest) { try { mdigest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } return mdigest; } public static String encode(String s) { if(null == s) { return ""; } try { byte[] bytes = s.getBytes(); getMdInst().update(bytes); byte[] md = getMdInst().digest(); int j = md.length; char str[] = new char[j * 2]; int k = 0; for(int i = 0; i < j; i++) { byte byte0 = md[i]; str[k++] = digits[byte0 >>> 4 & 0xf]; str[k++] = digits[byte0 & 0xf]; } return new String(str); } catch (Exception e) { e.printStackTrace(); return null; } } }
No example
<? php $params = ""; $params .= 'secret_key=***'.'&'; $params .= 'secret_code=81bb0620fbaf460db4e6dab84a05ec00'.'&'; $params .= 'secret_sign=md5(***)'.'&'; $params .= 'from='.'&'; $params .= 'to='.'&'; $params .= 'com='.'&'; $params .= 'orderTime='.'&'; $params .= substr($params, 0, -1); $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, ' http://cloud.kuaidi100.com/api '); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); echo $result; ?>
# coding = utf-8 import sys,os import requests,json,hashlib params = {} params['secret_key'] = '***' params['secret_code'] = '81bb0620fbaf460db4e6dab84a05ec00' params['secret_sign'] = 'md5(***)' params['from'] = '' params['to'] = '' params['com'] = '' params['orderTime'] = '' result = requests.post(' http://cloud.kuaidi100.com/api ', params) print(result.text)
{ "FromName": "Guangzhou", "fromNum": "CN440100000000", "ToName": "Kashi", "toNum": "CN653101000000", "orderTime": "2020-10-15 14:03:39", "returnCode": "200", "result": true, "Message": "Success", "TotalAvg": "6 days and 23 hours", "MayExpendTime": "7 days and 1 hour", "type": "10", "arrivalTime": "2020-10-22 15:00:00", "startTime": "2020-10-15 16:00:00", "proportionList": [ { "Day": "6 days and 23 hours", "proportion": "78.26%" } ], "maxRouteList": [ { "id": null, "Name": "Collect", "indexLevel": null, "mayStartTime": "16", "type": 0, "hourAvge": "0", "cid": "CN440112000000" }, { "id": "CN440112000000", "Name": "Huangpu District, Guangzhou City, Guangdong Province", "indexLevel": "3", "mayStartTime": "18", "type": 2, "hourAvge": "1", "cid": "CN650100000000" }, { "id": "CN650100000000", "Name": "Urumqi, Xinjiang", "indexLevel": "2", "mayStartTime": "4", "type": 1, "hourAvge": "77", "cid": "CN650107000000" }, { "id": "CN650107000000", "Name": "Aksu Township, Dabancheng District, Urumqi, Xinjiang", "indexLevel": "3", "mayStartTime": "6", "type": 1, "hourAvge": "0", "cid": "CN652900000000" }, { "id": "CN652900000000", "Name": "Xinjiang, Aksu Region", "indexLevel": "2", "mayStartTime": "2", "type": 2, "hourAvge": "34", "cid": "CN653101000000" }, { "id": "CN653101000000", "Name": "Xinjiang, Kashi Prefecture, Kashi City, Seman Township", "indexLevel": "3", "mayStartTime": "9", "type": 2, "hourAvge": "39", "cid": null }, { "id": null, "Name": "Dispatch", "indexLevel": null, "mayStartTime": "11", "type": 3, "hourAvge": "14", "cid": null }, { "id": null, "Name": "Sign in", "indexLevel": null, "mayStartTime": "11", "type": 4, "hourAvge": "2", "cid": null } ], "IsRecommendation": true,//whether it is a recommended route "RecommendFromCode": "CN440309020000",//The departure code of the recommended route "RecommendToCode": "CN653101000000",//The name of the departure place of the recommended route "RecommendFromName": "Guangdong, Shenzhen, Longhua District",//the destination code of the recommended route "RecommendToName": "Xinjiang, Kashi Prefecture, Kashi City, Seman Township"//The name of the destination of the recommended route }
{ "returnCode": "400", "Message": "The system is busy", }
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|