1.最近在整理微信接口,把代码放出来,很多部分都参考柳峰老师的微信公众平台应用
request:
public class BaseReqMsg {
// 开发者微信号
private String ToUserName;
// 发送方帐号(一个OpenID)
private String FromUserName;
// 消息创建时间 (整型)
private long CreateTime;
// 消息类型(text/image/location/link/shortvideo/video)
private String MsgType;
// 消息id,64位整型
private long MsgId;
public class ImageReqMsg extends BaseReqMsg {
//图片的url地址
private String PicUrl;
public String getPicUrl() {
return PicUrl;
}
public class LinkReqMsg extends BaseReqMsg {
private String Title;
private String Description;
//链接地址
private String Url;
public class LocationReqMsg extends BaseReqMsg {
private String Location_X;
private String Location_Y;
private String Scale;
private String Label;
public class TextReqMsg extends BaseReqMsg{
//推送的文本消息
private String Content;
public class VideoReqMsg extends BaseReqMsg {
//媒体ID
private String MediaId;
//缩略图的媒体Id
private String ThumbMediaId;
public class VoiceReqMsg extends BaseReqMsg {
//媒体的id
private String MediaId;
//语音格式
private String Format;
response:
public class BaseResMsg {
//接收方帐号(收到的OpenID)
private String ToUserName;
//开发者微信号
private String FromUserName;
//创建时间
private Long CreateTime;
//回复类型
private String MsgType;
public class ImageResMsg extends BaseResMsg{
private Image Image;
public class MusicResMsg extends BaseResMsg {
private Music Music;
public class NewsResMsg extends BaseResMsg {
private List<Article> Articles;
public List<Article> getArticles() {
return Articles;
}
public class TextResMsg extends BaseResMsg{
//回复的消息内容(换行:在content中能够换行,微信客户端就支持换行显示)
private String Content;
public class VideoResMsg extends BaseResMsg {
private Video Video;
public class VoiceResMsg extends BaseResMsg{
private Voice Voice;
event:
public class BaseEvent {
//开发者的微信号
private String ToUserName;
private String FromUserName;
private String CreateTime;
private String MsgType;
private String Event;
public class LocationEvent extends BaseEvent {
//地理位置纬度
private String Latitude;
//地理位置经度
private String Longitude;
//地理位置的精度
private String Precision;
public class MenuClickEvent extends BaseEvent {
//事件KEY值,与自定义菜单接口中KEY值对应
private String EventKey;
public class ScanEvent extends BaseEvent {
//事件key值
private String EventKey;
//二维码的ticket,可用来换取二维码图片
private String Ticket;
public class SubscribeEvent extends BaseEvent {
}
base:
public class Article {
private String Title;
private String Description; */
publ
private String PicUrl;
private String Url;
public class Image {
private String MediaId;
public class Music {
private String Title;
private String Description;
private String MusicUrl;
//高质量音乐链接,WIFI环境优先使用该链接播放音乐
private String HQMusicUrl;
//缩略图的媒体id,通过素材管理接口上传多媒体文件,得到的id
private String ThumbMediaId;
public class Video {
private String MediaId;
private String Title;
//视频消息的描述
private String Description;
public class Voice {
private String MediaId;