标签:
package com.wanhua.weixin.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import models.WeChatUser;
import play.i18n.Messages;
import com.alibaba.fastjson.JSON;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.wanhua.util.Const;
import com.wanhua.weixin.util.CDATA2Text;
import com.wanhua.weixin.util.WXConst;
import com.wanhua.weixin.util.XStream2Text;
import com.wanhua.weixin.util.XStreamCDATA;
/**
* 接收的事件消息
*
* @author w_xfpenga
*
* 2014-12-27
*/
@XStreamAlias("xml")
public class ReceEvent {
// 开发者微信号
@XStreamAlias("ToUserName")
@XStreamCDATA
public String ToUserName;
// 发送方帐号(一个OpenID)
@XStreamAlias("FromUserName")
@XStreamCDATA
public String FromUserName;
// 消息创建时间 (整型)
@XStreamAlias("CreateTime")
public String CreateTime;
// 消息类型:text,image,voice,video,location,link
@XStreamAlias("MsgType")
@XStreamCDATA
public String MsgType;
// 事件类型:CLICK
@XStreamAlias("Event")
@XStreamCDATA
public String Event;
// 事件KEY值,与自定义菜单接口中KEY值对应
@XStreamAlias("EventKey")
@XStreamCDATA
public String EventKey;
/**
* 接收到的xml转成ReceEvent对象
*
* @param xml
* @return
*/
public static ReceEvent parseReceEvent(String xml) {
ReceEvent receEvent = (ReceEvent) XStream2Text.xml2Object(xml);
return receEvent;
}
/**
* 将ReceEvent对象转成xml格式
*
* @param receEvent
* @return
*/
public static String parseXML(ReceEvent receEvent) {
String xml = XStream2Text.Object2Xml(receEvent);
return xml;
}
}
标签:
原文地址:http://www.cnblogs.com/xunfang123/p/4237135.html