被动回复用户消息,直接回复success或空字符串无效?
https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Passive_user_reply_message.html 接口地址 /**
* 微信服务器回调
*/
@Override
public String getOpenidAndTicket(HttpServletRequest request, HttpServletResponse response) throws Exception {
String message = "success";
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
Map<String, String> map = MessageUtil.xmlToMap(request);
log.info(":::::::::微信返回map::::::::" + map.toString());
String openid = map.get("FromUserName");
String kfz = map.get("ToUserName");
String MsgType = map.get("MsgType");
log.info(":::::::::MsgType::::::::" + MsgType);
log.info(":::::::::XConstants.MESSAGE_EVENT::::::::" + WXConstants.MESSAGE_EVENT);
if (MsgType.equals(WXConstants.MESSAGE_EVENT)) {
//从集合中,获取是哪一种事件传入
String eventType = map.get("Event");
//对获取到的参数进行处理
String eventKey = map.get("EventKey");
//扫描带参数的二维码,如果用户未关注,则可关注公众号,事件类型为subscribe;用户已关注,则事件类型为SCAN
String ticket = map.get("Ticket");
if (eventType.equals(WXConstants.MESSAGE_SUBSCRIBE)) {
// wxPolling(ticket);
// 创建document对象
Document document = DocumentHelper.createDocument();
// 创建根节点bookRoot
Element xml = document.addElement("xml");
// 向根节点中添加第一个节点
Element toUserName = xml.addElement("ToUserName");
// 向子节点中添加属性
toUserName.addCDATA(openid);
Element fromUserName = xml.addElement("FromUserName");
fromUserName.addCDATA(appFromUserName);
Element createTime = xml.addElement("CreateTime");
createTime.addCDATA(String.valueOf(System.currentTimeMillis()));
Element msgType = xml.addElement("MsgType");
msgType.addCDATA("text");
Element content = xml.addElement("Content");
content.addCDATA("关注回复");
message = document.getRootElement().asXML();
log.info("关注自动回复,openid{},回复信息为:{}", openid, message);
} e
}
log.info("返回微信服务器消息内容为:{}", message);
return message;
}
代码如上,第一次关注返回信息时正常,第二次扫码后会提示“该公众号提供的服务出现故障,请稍后再试”,请问是什么原因呢?