支持通过国际邮编查询对应的地区;或通过对应的国际地区查询邮编。支持日本、澳大利亚、意大利、马来西亚、泰国、西班牙、葡萄牙、瑞典、芬兰、奥地利、印度、德国、瑞士、加拿大、墨西哥、比利时、斯洛伐克、美国
无参数
无参数
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
secret_key | string | true | 用户授权key |
secret_code | string | true | 接口编号 |
secret_sign | string | true | 加密签名:md5(secret_key+secret_secret)转大写 |
country | string | true | 国家名称,如Thailand |
postcode | string | true | 邮政编码 |
curl http://cloud.kuaidi100.com/api -X POST -d \
"secret_key=***&secret_code=e71b24e15d45431a8e541f628437efdd&secret_sign=md5(***)&country=&postcode="
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", "e71b24e15d45431a8e541f628437efdd");
params.put("secret_sign", "md5(***)");
params.put("country", "");
params.put("postcode", "");
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=e71b24e15d45431a8e541f628437efdd'.'&';
$params .= 'secret_sign=md5(***)'.'&';
$params .= 'country='.'&';
$params .= 'postcode='.'&';
$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'] = 'e71b24e15d45431a8e541f628437efdd'
params['secret_sign'] = 'md5(***)'
params['country'] = ''
params['postcode'] = ''
result = requests.post('http://cloud.kuaidi100.com/api', params)
print(result.text)
无参数
{
"code": 200,
"message": "success",
"data": [
{
"recordId": "KoGKup2AHvEF",
"postcode": "36526",
"cn": "美国",
"en": "United States",
"state": "Alabama",
"county": "Baldwin",
"longitude": "-87.8895",
"latitude": "30.6197",
"city": "Daphne",
"community": ""
}
]
}
{
"code": -1,
"message": "系统繁忙",
"data": null
}
状态码 | 状态码信息 | 描述 |
---|---|---|
-1 | 系统繁忙 |
无参数
无参数
名称 | 类型 | 是否必须 | 描述 |
---|---|---|---|
secret_key | string | true | 用户授权key |
secret_code | string | true | 接口编号 |
secret_sign | string | true | 加密签名:md5(secret_key+secret_secret)转大写 |
country | string | true | 国家代号,如Thailand |
address | string | true | 需要查询的地址 |
curl http://cloud.kuaidi100.com/api -X POST -d \
"secret_key=***&secret_code=7cd7deffaa264a509b731abfa9f248ec&secret_sign=md5(***)&country=&address="
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", "7cd7deffaa264a509b731abfa9f248ec");
params.put("secret_sign", "md5(***)");
params.put("country", "");
params.put("address", "");
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=7cd7deffaa264a509b731abfa9f248ec'.'&';
$params .= 'secret_sign=md5(***)'.'&';
$params .= 'country='.'&';
$params .= 'address='.'&';
$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'] = '7cd7deffaa264a509b731abfa9f248ec'
params['secret_sign'] = 'md5(***)'
params['country'] = ''
params['address'] = ''
result = requests.post('http://cloud.kuaidi100.com/api', params)
print(result.text)
无参数
{
"code": 200,
"message": "success",
"data": [
{
"postcode": "3440066",
"country": "日本",
"state": "Saitama Ken",//州
"county": "Kasukabe Shi",//郡
"longitude": "139.7403",//
"latitude": "35.9697",
"city": "Yutakacho",//城市
"countryCode": "JP",//国家代号
"community": "",
"score": 22.121023//得分
}
]
}
{
"code": -1,
"message": "系统繁忙",
"data": null
}
状态码 | 状态码信息 | 描述 |
---|---|---|
-1 | 系统错误 |
支持通过国际邮编查询对应的地区;或通过对应的国际地区查询邮编。
支持以下国家及地区:日本、澳大利亚、意大利、马来西亚、泰国、西班牙、葡萄牙、瑞典、芬兰、奥地利、印度、德国、瑞士、加拿大、墨西哥、比利时、斯洛伐克、美国
代号列表:(区分大小写)
国家 |
代号 |
日本 |
Japan |
澳大利亚 |
Australia |
意大利 |
Italy |
马来西亚 |
Malaysia |
泰国 |
Thailand |
西班牙 |
Spain |
葡萄牙 |
Portugal |
瑞典 |
Sweden |
芬兰 |
Finland |
奥地利 |
Austria |
印度 |
India |
德国 |
Germany |
瑞士 |
Switzerland |
加拿大 |
Canada |
墨西哥 |
Mexico |
比利时 |
Belgium |
斯洛伐克 |
Slovakia |
美国 |
United States |