请求方式:GET/POST
请求地址:{domain}/track/listen?appKey={appKey}&content={content}&sign={sign}×tamp={timestamp}&version={version}
请求参数说明: ...
返回结果: ...
返回参数说明: ...
参数 | 类型 | 必须 | 说明 |
---|---|---|---|
appKey | string | 是 | 接口调用方身份标识 |
timestamp | long | 是 | 接口请求时间戳(毫秒级) |
sign | string | 是 | 各接口的请求参数经一定规则生成的摘要 |
content | string | 是 | 各接口的请求参数经一定规则生成的内容 |
version | int | 是 | 各接口版本,如各接口未说明,传1所有接口请求失效时间1分钟 |
public String sort(Map params) {
List<Map.Entry<String, Object>> argList = new LinkedList<Map.Entry<String,Object>>();
argList.addAll(params.entrySet());
Collections.sort(argList, Map.Entry.comparingByKey());
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> item : argList) {
String key = item.getKey();
String val = String.valueOf(item.getValue());
if (!(val == "" || val == null)) {
sb.append(key + "=" + val + "&");
}
}
return SecureUtil.md5(sb.toString());
}
import org.apache.tomcat.util.buf.HexUtils;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.security.Key;
/**
* requestParamsJson 转换为json字符串的请求参数
*/
public String encrypt(String requestParamsJson, String appSecret) throws Exception {
Cipher cipher = Cipher.getInstance("AES");
byte[] bs = HexUtils.fromHexString(appSecret);
Key key = new SecretKeySpec(bs,"AES");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[] p = requestParamsJson.getBytes("UTF-8");
byte[] result = cipher.doFinal(p);
String content = Base64Encoder.encode(result);
return content;
}