-
v1.0
可编辑可修改
常用快递
API
接口方案
电商企业从接收订单
-
配货
< br>-
打印快递单到后期的快递员收件
-
快递配送
-
轨迹查询
-
签收
短信通知等,都需要快递接口的接入。整理目前较为常见的接口
demo
如下:
对接流程:快递鸟网站申请接口—对接—联调测试—上线
预约取件
-
在线预约寄件
import
import
public class
KdGoldAPIDemo {
....
}
/**
return
result;
*
MD5
加密
*
@param str
内容
* @param charset
编码方式
* @throws Exception
*/
1
@SuppressWarnings(
private String MD5(String str, String
charset) throws Exception {
MessageDigest md = (
(charset));
byte[]
result = ();
StringBuffer sb = new StringBuffer(32);
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
UnsupportedEncodingEx
ception{
String encoded
= (charset));
return
encoded;
}
@SuppressWarnings(
private
String
urlEncoder(String
str,
String
charset)
throws
UnsupportedEncodingEx
ception{
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, charset),
charset);
return
base64(MD5(content + keyValue, charset),
charset);
*
向指定
URL
发送
POST
方法的请求
* @param url
发送请求的
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
*/
4
@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++)
{
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
UnsupportedEncodingEx
ception{
String encoded
= (charset));
return
encoded;
}
@SuppressWarnings(
private
String
urlEncoder(String
str,
String
charset)
throws
UnsupportedEncodingEx
ception{
5
}
String result = (str,
charset);
return
result;
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, charset),
charset);
return
base64(MD5(content + keyValue, charset),
charset);
*
向指定
URL
发送
POST
方法的请求
* @param url
发送请求的
URL
* @param params
请求的参数集合
* @return
远程资源的响应结果
*/
6
@SuppressWarnings(
private String sendPost(String url,
Map
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
UnsupportedEncodingEx
ception{
String encoded
= base64Encode(charset));
return encoded;
}
@SuppressWarnings(
private
String
urlEncoder(String
str,
String
charset)
throws
UnsupportedEncodingEx
ception{
8
}
/**
String result = (str,
charset);
return
result;
-
-
-
-
-
-
-
-
-
上一篇:高级英语常用词汇
下一篇:语法知识—名词的知识点