个人案例
这个贴我之前就查看过好几遍了,还是没看到哪里出冲击题了,麻烦再帮我指出具体问题
消息推送配置一直报“token校验失败,请检查确认”,这个是什么原因?我们的小程序要配置消息推送接收服务器,但是配置验证一直报“token校验失败,请检查确认”,排查了三天,一直没有找到原因。消息接收服务器能够收到验证请求,签名也验证通过,但是在配置页面上就一直显示“token校验失败,请检查确认”,这个问题出在哪里? 附图1:配置页面截图 [图片] 附图2:服务器端接收信息 [图片] 代码: String signature = request.getParameter("signature"); String timestamp = request.getParameter("timestamp"); String nonce = request.getParameter("nonce"); String echostr = request.getParameter("echostr"); String[] strarr = {PayCommonUtil.TOKEN, timestamp, nonce}; System.out.println("微信推送消息:"); System.out.println("signature:" + signature); System.out.println("timestamp:" + timestamp); System.out.println("nonce:" + nonce); System.out.println("echostr:" + echostr); Arrays.sort(strarr); StringBuilder sb = new StringBuilder(); for (String s : strarr) { // sb.append(s); } MD5Util md5util = new MD5Util(); String tempStr = md5util.SHA1Encode(sb.toString(), "UTF-8"); System.out.println("验证签名:"+tempStr); if (tempStr.equals(signature)) { // System.out.println("签名相同"); } /* long ts = System.currentTimeMillis()/1000; String tsstr = String.valueOf(ts); String[] strarr1 = {PayCommonUtil.TOKEN, tsstr, nonce}; Arrays.sort(strarr1); StringBuilder sb1 = new StringBuilder(); for (String s : strarr1) { // sb1.append(s); } String tempStr1 = md5util.SHA1Encode(sb1.toString(), "UTF-8"); JSONObject jsonobj = new JSONObject(); jsonobj.put("signature", signature); jsonobj.put("timestamp", timestamp); jsonobj.put("nonce", nonce); jsonobj.put("echostr", echostr); System.out.println(jsonobj.toJSONString()); */ System.out.println("回送echostr:"+echostr); response.setDateHeader("Expires", -1);//清空缓冲区 PrintWriter out1 = response.getWriter(); out1.print(echostr); out1.flush();
08-31