Response Code: 200
Response: {"session_key":"s5e9\/1DeB8UyOO0YsMxZEQ==","openid":"ohhBa5SnVFeO1dTS1PTQyYlp3KE4"}
openid:ohhBa5SnVFeO1dTS1PTQyYlp3KE4
colde: 0f1YuPGa17sRlG0L41Ja16FwYk1YuPGg
session_key: s5e9/1DeB8UyOO0YsMxZEQ==
rawData: {"nickName":"小杨同学","gender":0,"language":"zh_CN","city":"","province":"","country":"","avatarUrl":"https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTL5fzC8pBD28oSTDNicFh333dKMQKgLxHfoWc0FNqZibu3K0qsJbPxKlQAicYSzibkw5VAh21Az69ibcXQ/132"}
signature :f8cf8ad973e4109a4a50bcf139a3af938206d998
Response_access_token: 74_8VFarlnhberhVIw087kw6csqHd_Ohh55_S6dV6_yG-sJN3zoH2oXI0r_tYZRMB8K7xGAF4vS_9Vc0sjyTb8k-M4ig-HHIUFQxt-Kz52_DAhoBqK1P56C9_KW3LkAEVhAAADHY
access_token : 74_8VFarlnhberhVIw087kw6csqHd_Ohh55_S6dV6_yG-sJN3zoH2oXI0r_tYZRMB8K7xGAF4vS_9Vc0sjyTb8k-M4ig-HHIUFQxt-Kz52_DAhoBqK1P56C9_KW3LkAEVhAAADHY
自己加密的与微信返回的sigtrue一致,还是返回errcode":87009,"errmsg":"invalid signature rid,求大神解答
/**
* 检查sessionkey是否有效
*
* @date 2023/10/30 16:38
*/
public static String sessiontimeliness(String date ,String sessionkey ,String openids) {
String errcode =null;
// 替换以下值为实际的 ACCESS_TOKEN、SIGNATURE、OPENID 和 SIG_METHOD
String access_token = getcredential();
System.out.println("access_token : " + access_token);
String signature = getUserSignature(date,sessionkey);
String openid = openids;
String sig_method = "hmac_sha256";//;getUsersig_method(date,sessionkey)
// 构建请求URL getUsersig_method(date,sessionkey)
String apiUrl = "https://api.weixin.qq.com/wxa/checksession" +
"?access_token=" + access_token +
"&signature=" + signature +
"&openid=" + openid +
"&sig_method=" + sig_method;
System.out.println("验证Session-key ----apiUrl:"+apiUrl);
try {
URL url = new URL(apiUrl);
// 打开连接
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 设置请求方法为GET
connection.setRequestMethod("GET");
// 获取响应
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
// 输出响应结果
System.out.println("检查sessionkey时效__Response:\n" + response.toString());
JSONObject jsonObject = JSON.parseObject(response.toString());
errcode = jsonObject.getString("errcode");
// 关闭连接
connection.disconnect();
} catch (Exception e) {
throw new RuntimeException(e);
}
return errcode;
}
/**
* 获取signature
*
* @date 2023/10/30 16:38
* <p>
* <p>
* String datas, String secretKey
*/staticStringStringStringStringnullString"拼接后的串:=======*************"try// 创建SHA-1消息摘要对象"SHA-1"// 将字符串转换为字节数组// 计算哈希值// 将哈希值转换为十六进制字符串newforString0xffif1'0'"Signature加密后的值:"catch"SHA-1 algorithm is not available."return sha1;
}
所以rid是多少
解决了吗