可按省、市、快递公司查询某地快递服务是否恢复
无参数
无参数
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
secret_key | string | true | 用户授权key |
secret_code | string | true | 接口编号 |
secret_sign | string | true | 加密签名:md5(secret_key+secret_secret)转大写 |
method | string | true | 业务类型(查省份:province、查市:city、线路快递可行性:line) |
com | string | false | 快递编码(需要查询的快递公司,快递公司对应的编码请参考”产品详情”中的快递公司编码表) |
xzqName | string | false | 行政区名(当method为province,该项为选填,填写省级行政区名;当method为city,该项为选填,填写市级行政区名) |
send | string | false | 寄件地(当method为line,该项为选填) |
rec | string | false | 收件地(当method为line,该项为选填) |
curl http://cloud.kuaidi100.com/api -X POST -d \
"secret_key=***&secret_code=3d02021ba7534900b60681b0f9115e07&secret_sign=md5(***)&method=&com=&xzqName=&send=&rec="
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", "3d02021ba7534900b60681b0f9115e07");
params.put("secret_sign", "md5(***)");
params.put("method", "");
params.put("com", "");
params.put("xzqName", "");
params.put("send", "");
params.put("rec", "");
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;
}
}
}
暂无示例
<?php
$params = "";
$params .= 'secret_key=***'.'&';
$params .= 'secret_code=3d02021ba7534900b60681b0f9115e07'.'&';
$params .= 'secret_sign=md5(***)'.'&';
$params .= 'method='.'&';
$params .= 'com='.'&';
$params .= 'xzqName='.'&';
$params .= 'send='.'&';
$params .= 'rec='.'&';
$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'] = '3d02021ba7534900b60681b0f9115e07'
params['secret_sign'] = 'md5(***)'
params['method'] = ''
params['com'] = ''
params['xzqName'] = ''
params['send'] = ''
params['rec'] = ''
result = requests.post('http://cloud.kuaidi100.com/api', params)
print(result.text)
无参数
{
"result":true,
"returnCode":"200",
"message":"成功",
"data": {"com":"shunfeng","lsCheck":true,"lsCount":41125,"pjCheck":true,"pjCount":11838,"xzqCode":"440300000000","xzqFullName":"广东,深圳市"}
}
{
"result":true,
"returnCode":"500",
}
状态码 | 状态码信息 | 描述 |
---|---|---|
200 | 成功 | 成功 |
500 | 服务器错误 | 服务器错误 |
无参数
无参数
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
secret_key | string | true | 用户授权key |
secret_code | string | true | 接口编号 |
secret_sign | string | true | 加密签名:md5(secret_key+secret_secret)转大写 |
method | string | true | 业务类型(默认:province) |
com | string | true | 快递编码 |
curl http://cloud.kuaidi100.com/api -X POST -d \
"secret_key=***&secret_code=fbd6ee436d8746db81cd0ef368592b1e&secret_sign=md5(***)&method=&com="
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", "fbd6ee436d8746db81cd0ef368592b1e");
params.put("secret_sign", "md5(***)");
params.put("method", "");
params.put("com", "");
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;
}
}
}
暂无示例
<?php
$params = "";
$params .= 'secret_key=***'.'&';
$params .= 'secret_code=fbd6ee436d8746db81cd0ef368592b1e'.'&';
$params .= 'secret_sign=md5(***)'.'&';
$params .= 'method='.'&';
$params .= 'com='.'&';
$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'] = 'fbd6ee436d8746db81cd0ef368592b1e'
params['secret_sign'] = 'md5(***)'
params['method'] = ''
params['com'] = ''
result = requests.post('http://cloud.kuaidi100.com/api', params)
print(result.text)
无参数
状态码 | 状态码信息 | 描述 |
---|
用户可通过该接口,查询某地的快递服务是否恢复,优化电商发货,提高产品体验
1、可按省、市查询某查询快递是否恢复;
2、可查询具体某一快递是否恢复;
3、返回快递区域百分比和推荐快递属性;
返回结果
字段 |
类型 |
说明 |
备注 |
result |
boolean |
提交结果 |
true成功,false失败 |
returnCode |
String |
返回编码 |
|
message |
String |
返回报文描述 |
|
data |
data |
数据对象 |
|
data数据结构:
参数名 |
类型 |
说明 |
com |
String |
快递公司编码 |
lsCheck |
Boolean |
是否揽件,true接受揽件,false,拒绝揽件 |
lsCount |
Integer |
揽件数 |
lsPercentage |
String |
揽收占据百分比 |
pjCheck |
Boolean |
是否派件,true接受派件,false,拒绝派件 |
pjCount |
Integer |
派件数 |
pjPercentage |
String |
派件占据百分比 |
xzqCode |
String |
行政区编码 |
xzqFullName |
String |
行政区名称 |
recommend |
String |
推荐程度,10:中立,20:不推荐,30:推荐 |
参数com(快递公司)请使用该表对应的编码
快递公司编码表:
http://api.kuaidi100.com/manager/openapi/download/kdbm.do