Commit f25c6a33 authored by liyang's avatar liyang
Browse files

1.消息推送配置,智能回复

parent a2838dd8
package org.linlinjava.litemall.wx.web; package org.linlinjava.litemall.wx.web;
import cn.binarywang.wx.miniapp.api.WxMaService; 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.bean.WxMaMessage;
import cn.binarywang.wx.miniapp.message.WxMaXmlOutMessage; import cn.binarywang.wx.miniapp.message.WxMaXmlOutMessage;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
...@@ -12,8 +13,6 @@ import org.springframework.web.bind.annotation.*; ...@@ -12,8 +13,6 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/** /**
* @author liyang * @author liyang
...@@ -65,16 +64,9 @@ public class WxMsgController { ...@@ -65,16 +64,9 @@ public class WxMsgController {
String msgType = wxMaMessage.getMsgType(); String msgType = wxMaMessage.getMsgType();
if ("text".equals(msgType)) { if ("text".equals(msgType)) {
try { try {
Map<String, Object> msg = new HashMap<>(); wxMaService.getMsgService().sendKefuMsg(WxMaKefuMessage.newTextBuilder().content(wxMaMessage.getContent()).toUser(wxMaMessage.getFromUser()).build());
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);
} catch (WxErrorException e) { } catch (WxErrorException e) {
e.printStackTrace(); logger.error("消息自动回复失败");
} }
} }
WxMaXmlOutMessage wxMaXmlOutMessage = new WxMaXmlOutMessage(); WxMaXmlOutMessage wxMaXmlOutMessage = new WxMaXmlOutMessage();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment