微信开发在本地设置了关键词的自动回复。一个关键词设置回复最多5条回复信息,可以是文本、图片、图文消息。回复方式有随机回复和全部回复,在网上查找资料,现在只实现了回复一条消息,求问怎么实现全部回复。求提供思路
返回一条实现:
返回一条实现:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 将请求、响应的编码均设置为UTF-8(防止中文乱码) request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); // 接收参数微信加密签名、 时间戳、随机数 String signature = request.getParameter("signature"); String timestamp = request.getParameter("timestamp"); String nonce = request.getParameter("nonce"); PrintWriter out = response.getWriter(); // 请求校验 boolean checkSignature = SignUtil.checkSignature(signature, timestamp, nonce); if (checkSignature) { // 调用核心服务类接收处理请求 String respXml = processRequest(request); out.print(respXml); } out.close(); out = null; }
解决方案
40