收藏
回答

Token校验失败,请检查确认?

@RequestMapping(value = "member/getSignature", method = {RequestMethod.POST, RequestMethod.GET})
@NoRepeatSubmit
@ApiOperation(value = "消息回调")
@NoRepeatWebLog
public String getSignature(HttpServletRequest request, HttpServletResponse response) throws Exception {
    //微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数
    boolean isGet = request.getMethod().toLowerCase().equals("get");
    if (isGet) {
        String signature = request.getParameter("signature");
        // 时间戳
        String timestamp = request.getParameter("timestamp");
        // 随机数
        String nonce = request.getParameter("nonce");
        // 随机字符串
        String echostr = request.getParameter("echostr");
        log.info("echostr>>>>>>>>>>" + echostr);
        //通过检验signature对请求进行校验,若校验成功则原样返回echostr,否则接入失败
        if (WechatUtil.checkSignature(signature, timestamp, nonce)) {
            log.info("echostr>>>>>>>>>>>>" + echostr);
            System.out.println(echostr);
            return echostr;
        }
        log.info("客服消息验证url验证结果:{}", echostr);
    } else {
        WechatUtil.response(request, response);
    }
    return null;
}



 
            

echostr>>>>>>>>>>5347601719758867709

客服消息验证url验证结果:5347601719758867709

最后一次编辑于  06-03
回答关注问题邀请回答
收藏

1 个回答

  • Mr.Zhao
    Mr.Zhao
    06-03

    乱七八糟的啥玩意啊,咋看

    06-03
    有用
    回复 4
    • stone
      stone
      06-03
      刷新一下
      06-03
      回复
    • Mr.Zhao
      Mr.Zhao
      06-03回复stone
      看不懂,return了,下面的log还会打印?
      06-03
      回复
    • stone
      stone
      06-03回复Mr.Zhao
      忘记return echostr。可以了
      06-03
      回复
    • Mr.Zhao
      Mr.Zhao
      06-03回复stone
      好尴尬啊。@GetMaping @PostMaping注解不能用吗,在一个接口里面写if else判断get,堆屎山
      06-03
      回复
登录 后发表内容