收藏
回答

"errcode":87009,"errmsg":"invalid signature rid: ?

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;
}
回答关注问题邀请回答
收藏

2 个回答

  • Demons
    Demons
    2023-11-06

    所以rid是多少

    2023-11-06
    有用
    回复 7
    • 小杨同学
      小杨同学
      发表于移动端
      2023-11-06
      明早去公司发给你
      2023-11-06
      回复
    • 小杨同学
      小杨同学
      2023-11-07
      {"errcode":87009,"errmsg":"invalid signature rid: 6549917e-71d4fa9b-568b2542"}
      2023-11-07
      回复
    • 友信
      友信
      2023-12-25
      我也遇到了同样的问题,哥们儿你的问题解决了吗?
      2023-12-25
      回复
    • 友信
      友信
      2023-12-25
      你好,我也遇到了同样的问题,Errcode:87009 Errmsg:invalid signature rid: 6588f6b6-23c87c5f-771210a4
      2023-12-25
      回复
    • 友信
      友信
      2023-12-25回复小杨同学
      哥们儿,你的问题解决了吗?我也遇到了同样的问题
      2023-12-25
      回复
    查看更多(2)
  • 梅杰
    梅杰
    06-01

    解决了吗

    06-01
    有用
    回复
登录 后发表内容