Skip to content

Commit

Permalink
1.消息推送配置,智能回复
Browse files Browse the repository at this point in the history
  • Loading branch information
liyang committed Nov 11, 2021
1 parent a2838dd commit f25c6a3
Showing 1 changed file with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.linlinjava.litemall.wx.web;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaKefuMessage;
import cn.binarywang.wx.miniapp.bean.WxMaMessage;
import cn.binarywang.wx.miniapp.message.WxMaXmlOutMessage;
import me.chanjar.weixin.common.error.WxErrorException;
Expand All @@ -12,8 +13,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* @author liyang
Expand Down Expand Up @@ -65,16 +64,9 @@ public String config(HttpServletRequest request, HttpServletResponse response) {
String msgType = wxMaMessage.getMsgType();
if ("text".equals(msgType)) {
try {
Map<String, Object> msg = new HashMap<>();
Map<String, String> body = new HashMap<>();
msg.put("access_token", wxMaService.getAccessToken());
msg.put("touser", wxMaMessage.getFromUser());
msg.put("msgtype", wxMaMessage.getMsgType());
body.put("content", wxMaMessage.getContent());
msg.put("text", body);
wxMaService.post("https://api.weixin.qq.com/cgi-bin/message/custom/send", msg);
wxMaService.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content(wxMaMessage.getContent()).toUser(wxMaMessage.getFromUser()).build());
} catch (WxErrorException e) {
e.printStackTrace();
logger.error("消息自动回复失败");
}
}
WxMaXmlOutMessage wxMaXmlOutMessage = new WxMaXmlOutMessage();
Expand Down

0 comments on commit f25c6a3

Please sign in to comment.