-
v1.0
可编辑可修改
常用快递
API
接口方案
电商企业从接收订单
-
配货
-
打印快递单到后期的快递员收件
短信通知等,都需要快递接口的接入。整理目前较为常见的接口
对接流程:快递鸟网站申请接口—对接—联调测试—上线
-
快递配送
-
轨迹查询
-
签收
demo
如下:
预约取件
-
在线预约寄件
import
import
public
class KdGoldAPIDemo {
....
return
result;
}
/**
*
MD5
加密
内容
编码方式
* @param
str
* @param
charset
* @throws
Exception
*/
@SuppressWarnings(
private String MD5(String str, String
charset) throws Exception {
MessageDigest md = (
(charset));
byte[] result = ();
StringBuffer sb = new
StringBuffer(32);
1
v1.0
可编辑可修改
for (int i
= 0; i < i++) {
int val =
result[i] & 0xff;
if (val <=
0xf) {
(
}
(val));
}
return
().toLowerCase();
}
/**
* base64
* @param
str
* @param
charset
编码
内容
编码方式
* @throws
UnsupportedEncodingException
*/
private
String
base64(String
str,
String
charset)
throws
Unsupporte
dEncodingException{
String
encoded = (charset));
return
encoded;
}
@SuppressWarnings(
private
String
urlEncoder(String
str,
String
charset)
throws
Unsupporte
dEncodingException{
String
result = (str, charset);
return result;
2
v1.0
可编辑可修改
}
/**
*
电商
Sign
签名生成
内容
* @param
content
* @param keyValue
Appkey
* @param
charset
编码方式
* @throws UnsupportedEncodingException
,Exception
* @return
DataSign
*/
@SuppressWarnings(
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);
}
/**
*
向指定
URL
发送
POST
方法的请求
发送请求的
URL
请求的参数集合
* @param
url
* @param
params
* @return
*/
远程资源的响应结果
3
v1.0
可编辑可修改
@SuppressWarnings(
private String sendPost(String url,
Map
OutputStreamWriter out =
null;
BufferedReader in =
null;
StringBuilder result =
new StringBuilder();
try
{
URL realUrl = new
URL(url);
HttpURLConnection
conn =(HttpURLConnection) ();
....
return
result;
}
/**
*
MD5
加密
内容
编码方式
* @param
str
* @param
charset
* @throws
Exception
*/
@SuppressWarnings(
private String MD5(String str, String
charset) throws Exception {
MessageDigest md = (
(charset));
byte[] result = ();
StringBuffer sb = new
StringBuffer(32);
for (int i
= 0; i < i++) {
4
v1.0
可编辑可修改
int val =
result[i] & 0xff;
if (val <=
0xf) {
(
}
(val));
}
return
().toLowerCase();
}
/**
* base64
* @param
str
* @param
charset
编码
内容
编码方式
* @throws
UnsupportedEncodingException
*/
private
String
base64(String
str,
String
charset)
throws
Unsupporte
dEncodingException{
String
encoded = (charset));
return
encoded;
}
@SuppressWarnings(
private
String
urlEncoder(String
str,
String
charset)
throws
Unsupporte
dEncodingException{
String
result = (str, charset);
return result;
}
5
v1.0
可编辑可修改
/**
*
电商
Sign
签名生成
内容
* @param
content
* @param keyValue
Appkey
* @param
charset
编码方式
* @throws UnsupportedEncodingException
,Exception
* @return
DataSign
*/
@SuppressWarnings(
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);
}
/**
*
向指定
URL
发送
POST
方法的请求
发送请求的
URL
请求的参数集合
* @param
url
* @param
params
* @return
*/
远程资源的响应结果
@SuppressWarnings(
private String sendPost(String url,
Map
6
v1.0
可编辑可修改
OutputStreamWriter out =
null;
BufferedReader in =
null;
StringBuilder result =
new StringBuilder();
try
{
URL realUrl = new
URL(url);
HttpURLConnection
conn =(HttpURLConnection) ();
....
return
result;
}
/**
*
MD5
加密
内容
编码方式
* @param
str
* @param
charset
* @throws
Exception
*/
@SuppressWarnings(
private String MD5(String str, String
charset) throws Exception {
MessageDigest md = (
(charset));
byte[] result = ();
StringBuffer sb = new
StringBuffer(32);
for (int i
= 0; i < i++) {
int val =
result[i] & 0xff;
7
v1.0
可编辑可修改
if (val <=
0xf) {
(
}
(val));
}
return
().toLowerCase();
}
/**
* base64
* @param
str
* @param
charset
编码
内容
编码方式
* @throws
UnsupportedEncodingException
*/
private
String
base64(String
str,
String
charset)
throws
Unsupporte
dEncodingException{
String
encoded = base64Encode(charset));
return encoded;
}
@SuppressWarnings(
private
String
urlEncoder(String
str,
String
charset)
throws
Unsupporte
dEncodingException{
String
result = (str, charset);
return result;
}
/**
8
-
-
-
-
-
-
-
-
-
上一篇:初中英语名词动词变化规律
下一篇:Allegro 中封装焊盘命名规则设计方法