收藏
回答

小程序开发管理配置了消息推送不生效

框架类型 问题类型 操作系统 工具版本
小程序 Bug Windows weixin-java-miniapp 4.1.0
@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 {
        // 关键:直接返回echostr原值,不要任何包装
        response.setContentType("text/plain;charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print(echostr); // 直接输出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);
        }
    }
}

/**
 * 接收事件推送(POST请求)
 * 简化版XML处理
 */
@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 接口


最后一次编辑于  2025-09-19
回答关注问题邀请回答
收藏

2 个回答

  • 🦘 啊太同学
    🦘 啊太同学
    2025-09-19

    1.你们没有报错,只是单纯没有推送数据包到我服务器(按你们的文档介绍,你们会推送)

    2.小程序授权获取头像和手机号,然后手机取消授权

    3.代码已上传

    2025-09-19
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    2025-09-19
    有用
    回复
登录 后发表内容