@GetMapping("/callback")
public void verifyWeChatServer(
@RequestParam("signature") String signature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam("echostr") String echostr,
HttpServletResponse response) {
String content= "signature="+signature+",timestamp="+timestamp+",nonce="+nonce+",echostr="+echostr;
try {
response.setContentType("text/plain;charset=UTF-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
out.print(echostr);
out.flush();
} catch (Exception e) {
log.error("❌ 验证过程中发生异常", e);
try {
response.setContentType("text/plain;charset=UTF-8");
response.getWriter().print("");
} catch (IOException ex) {
log.error("❌ 发送错误响应失败", ex);
}
}
}
@PostMapping(value = "/callback", produces = "application/xml;charset=UTF-8")
public String handleEvent(@RequestBody JSONObject jsonObject) {
try {
emailCodeSender.easySend("收到微信用户操作事件数据包",JSONObject.toJSONString(jsonObject),"sportsu@xxx.com");
return "success";
} catch (Exception e) {
log.error("处理微信事件失败", e);
return "failure";
}
}
在你们平台的小程序开发者中配置了消息推送,用来接收用户取消授权时的数据包推送,没有生效,你们没有推送数据包到我的callback 接口
1.你们没有报错,只是单纯没有推送数据包到我服务器(按你们的文档介绍,你们会推送)
2.小程序授权获取头像和手机号,然后手机取消授权
3.代码已上传