Package com.qq.weixin.sdk.message

Examples of com.qq.weixin.sdk.message.MessageResultNews


    return messageResultText;
  }

  // build result message news
  protected Message buildMessageResultNews(List<ItemArticle> items) {
    MessageResultNews messageResultNews = new MessageResultNews();
    messageResultNews.setMsgType(MESSAGE_RESULT_NEWS);
    messageResultNews.setCreateTime(getCurrentUnixTimestamp());
    messageResultNews.setFromUserName(message.getToUserName());
    messageResultNews.setToUserName(message.getFromUserName());
    messageResultNews.setArticleItems(items);
    messageResultNews.setCount(items.size());
    messageResultNews.setFuncFlag(1);//
    return messageResultNews;
  }
View Full Code Here


*/
public class MessageResultHandlerNews extends MessageResultHandlerHelper {

  @Override
  public String buildMessageResult(Message message) {
    MessageResultNews messageResultNews = (MessageResultNews) message;
    StringBuffer buffer = new StringBuffer();
    StringBuffer items = new StringBuffer();
    StringBuffer item = new StringBuffer();
    ItemArticle itemArticle = null;
    for (int i = 0; i < messageResultNews.getCount(); i++) {
      item = new StringBuffer();// important!easy to miss
      itemArticle = messageResultNews.getArticleItems().get(i);
      item.append(wrapperContent(TAG_TITLE, itemArticle.getTitle(), true))
          .append(wrapperContent(TAG_DESCRIPTION, itemArticle.getDescription(), true))
          .append(wrapperContent(TAG_PICURL, itemArticle.getPicUrl(), true))
          .append(wrapperContent(TAG_URL, itemArticle.getUrl(), true));
      items.append(wrapperContent(TAG_ITEM, item.toString(), false));
    }
    String articles = wrapperContent(TAG_ARTICLES, items.toString(), false);
    buffer.append(wrapperContent(TAG_TOUSERNAME, messageResultNews.getToUserName(), true))
        .append(wrapperContent(TAG_FROMUSERNAME, messageResultNews.getFromUserName(), true))
        .append(wrapperContent(TAG_CREATETIME, messageResultNews.getCreateTime() + "", false))
        .append(wrapperContent(TAG_MSGTYPE, messageResultNews.getMsgType(), true))
        .append(wrapperContent(TAG_ARTICLECOUNT, messageResultNews.getCount() + "", false)).append(articles)
        .append(wrapperContent(TAG_FUNCFLAG, messageResultNews.getFuncFlag() + "", false));
    return wrapperXmlContent(buffer.toString());
  }
View Full Code Here

TOP

Related Classes of com.qq.weixin.sdk.message.MessageResultNews

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.