package com.yihu.wlyy.wechat.util; import java.util.Date; import java.util.List; import java.util.Map; /** * 消息回复工具类 * * Created by lyr on 2016/08/15. */ public class WeiXinMessageReplyUtils { /** * 回复图文消息 * * @param toUser * @param fromUser * @param articles * @return * @throws Exception */ public static String replyNewsMessage(String toUser,String fromUser,List> articles) throws Exception { if(articles == null || articles.size() < 1){ throw new Exception("图文信息不能为空!"); } StringBuilder result = new StringBuilder(); result.append(""); result.append("" + toUser + ""); result.append("" + fromUser + ""); result.append("" + new Date().getTime() + ""); result.append("news"); result.append("" + articles.size() + ""); result.append(""); for(Map article : articles){ result.append(""); result.append("" + article.get("Title") +""); result.append("" + article.get("Description") + ""); result.append("" + article.get("PicUrl") + ""); result.append("" + article.get("Url") + ""); result.append(""); } result.append(""); result.append(""); return result.toString(); } }