我也遇到了同样的问题,一直配置失败
测试号,接口配置信息如何配置?[图片][图片] 我直接返回 echostr ,一直是配置失败
2022-08-30我也遇到了一样的问题,用测试号一直配置不成功,请问有解决了吗 这个问题
接入公众平台接口配置信息不成功?测试公众平台配置及调用效果如下: [图片] 后台代码如下: @GetMapping("/handleWxCheckSignature") public String handleWxCheckSignature ( HttpServletRequest request) throws Exception { log.info("===========>checkSign"); //获取微信请求参数 String signature = request.getParameter ("signature"); String timestamp = request.getParameter ("timestamp"); String nonce = request.getParameter ("nonce"); String echostr = request.getParameter ("echostr"); log.info("开始校验此次消息是否来自微信服务器,param->signature:{},\ntimestamp:{},\nnonce:{},\nechostr:{}", signature, timestamp, nonce, echostr); boolean checkFlag = this.checkSignature(signature, timestamp, nonce); log.info("校验是否成功结果:{}",checkFlag); if (checkFlag) { return echostr; } return ""; } 加解密代码如下: public static boolean checkSignature(String signature, String timestamp, String nonce) { String[] arr = {"qweasdzxc", timestamp, nonce}; Arrays.sort(arr); StringBuilder stringBuilder = new StringBuilder(); for (String param : arr) { stringBuilder.append(param); } String hexString = SHA1(stringBuilder.toString()); return signature.equals(hexString); } private static String SHA1(String str) { MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); byte[] digest = md.digest(str.getBytes()); return toHexString(digest); } catch (NoSuchAlgorithmException e) { log.info("校验令牌Token出现错误:{}", e.getMessage()); } return ""; } /** * 字节数组转化为十六进制 * * @param digest 字节数组 * @return String */ private static String toHexString(byte[] digest) { StringBuilder hexString = new StringBuilder(); for (byte b : digest) { String shaHex = Integer.toHexString(b & 0xff); if (shaHex.length() < 2) { hexString.append(0); } hexString.append(shaHex); } return hexString.toString(); } 解密后返回值为true,已经按照文档要求返回echostr 参数内容,依旧提示配合失败,请问是什么原因 [图片]
2022-08-30