private static String getSign(Map<String,String> nutMap, String urlData, String session_key) {
Set<String> set1 = nutMap.keySet();
String[] arrayToSort1 = set1.toArray(new String[set1.size()]);
Arrays.sort(arrayToSort1,String.CASE_INSENSITIVE_ORDER);
StringBuilder stringBuilder1 = new StringBuilder("");
for (String str : arrayToSort1) {
if (stringBuilder1.toString().equals("")) {
stringBuilder1.append(str + "=" + nutMap.get(str));
} else {
stringBuilder1.append("&" + str + "=" + nutMap.get(str));
}
}
log.info("buy|stringBuilder1=" + stringBuilder1.toString());
String temp = "";
try {
stringBuilder1.append(urlData);
// log.info("buy|stringBuilder1=" + stringBuilder1.toString());
temp = SnsSigCheck.encodeUrl(stringBuilder1.toString());
log.info("buy|aaaaaaaaaa=" + stringBuilder1.toString().equals(temp));
}catch (Exception e){
}
String mp_sig = null;//
try {
Mac mac = Mac.getInstance("HmacSHA256");
SecretKeySpec secretKey = new SecretKeySpec(session_key.getBytes("UTF-8"), mac.getAlgorithm());
mac.init(secretKey);
byte[] hash = mac.doFinal(temp.getBytes("UTF-8"));
mp_sig = new String(Base64Coder.encode(hash));
}catch (Exception e){
Logs.get().error("=========e="+ Lang.getStackTrace(e));
}
return mp_sig;
}
你好,可以尝试参考下面这个回答,看看是否有帮助
小游戏虚拟支付报签名错误
https://developers.weixin.qq.com/blogdetail?action=get_post_info&docid=00044e0fd584b808ef8658d2156800&highline=90009
问题是排序后的内容也是一样的呀,url中也有accessToken,而body中没有accessToken的内容呀
麻烦提供下报错的大致时间点
今天16点左右
"errcode": 90009,
"errmsg": "mp_sig error hint: [m7hsEA05873139]"
你这url参数拼接结果和顺序是对的么?日志打印看看。
appid=wxe0e6a8746dd227ed&offer_id=1450015771&openid=ohDof5VgEagodazWz8adnMa17-7A&pf=android&ts=1530257189&zone_id=1
拼接顺序是对的,已经对过了
access token 过期了?
刚刚请求的accessToken,不可能马上就过期呀
错误信息都没有啊。
"errcode": 90009,
"errmsg": "mp_sig error hint: [m7hsEA05873139]"
有没有demo来运行一下呀