示例代码:
@GetMapping("")
public String checkSignature(@RequestParam(value = "timestamp") String timestamp,
@RequestParam(value = "nonce") String nonce,
@RequestParam(value = "signature") String signature,
@RequestParam(value = "echostr") Integer echostr) {
boolean result = wxMpService.checkSignature(timestamp, nonce, signature);
if (result) {
return echostr;
} else {
return "checkSignature error";
}
}
死活验证不过去,百度半天没人给出正确的解决办法。最后终于找到了解决办法,把echostr改成Long类型,验证成功
@GetMapping("")
public Long checkSignature(@RequestParam(value = "timestamp") String timestamp,
@RequestParam(value = "nonce") String nonce,
@RequestParam(value = "signature") String signature,
@RequestParam(value = "echostr") Long echostr) {
boolean result = wxMpService.checkSignature(timestamp, nonce, signature);
if (result) {
return echostr;
} else {
return 0L;
}
}
微信真的是坑啊,名字叫echostr,第一反应当然认为是一个字符串,结果是个数字???