java开发微信公众号3

时间:2022-12-22 23:10:44

发送方消息处理

消息基类

java开发微信公众号3java开发微信公众号3
public class BaseMessage {
//接收方账号(收到的openId)
private String ToUserName;
//开发者微信号
private String FromUserName;
//消息创建时间(整型)
private long CreateTime;
//消息类型(text/music/news)
private String MsgType;
//位0x0001 被标记时,星标刚收到的消息
private int FuncFlag;
public String getToUserName() {
return ToUserName;
}
public void setToUserName(String toUserName) {
ToUserName
= toUserName;
}
public String getFromUserName() {
return FromUserName;
}
public void setFromUserName(String fromUserName) {
FromUserName
= fromUserName;
}
public long getCreateTime() {
return CreateTime;
}
public void setCreateTime(long createTime) {
CreateTime
= createTime;
}
public String getMsgType() {
return MsgType;
}
public void setMsgType(String msgType) {
MsgType
= msgType;
}
public int getFuncFlag() {
return FuncFlag;
}
public void setFuncFlag(int funcFlag) {
FuncFlag
= funcFlag;
}
}
BaseMessage

链接消息

java开发微信公众号3java开发微信公众号3
public class LinkMessage extends BaseMessage{
//消息标题
private String Title;
//消息描述
private String Description;
//消息链接
private String Url;
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title
= title;
}
public String getDescription() {
return Description;
}
public void setDescription(String description) {
Description
= description;
}
public String getUrl() {
return Url;
}
public void setUrl(String url) {
Url
= url;
}
}
LinkMessage

位置消息

java开发微信公众号3java开发微信公众号3
public class LocationMessage extends BaseMessage {
//地理位置维度
private String Location_X;
//地理位置经度
private String Location_Y;
//地图缩放大小
private String Scale;
//地理位置信息
private String Label;
public String getLocation_X() {
return Location_X;
}
public void setLocation_X(String locationX) {
Location_X
= locationX;
}
public String getLocation_Y() {
return Location_Y;
}
public void setLocation_Y(String locationY) {
Location_Y
= locationY;
}
public String getScale() {
return Scale;
}
public void setScale(String scale) {
Scale
= scale;
}
public String getLabel() {
return Label;
}
public void setLabel(String label) {
Label
= label;
}
}
LocationMessage

文本消息

java开发微信公众号3java开发微信公众号3
public class TextMessage extends BaseMessage{
//消息内容
private String content;

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

}
TextMessage

语音消息

java开发微信公众号3java开发微信公众号3
public class VoiceMessage extends BaseMessage{
//媒体Id
private String MediaId;
//语音格式
private String Format;
public String getMediaId() {
return MediaId;
}
public void setMediaId(String mediaId) {
MediaId
= mediaId;
}
public String getFormat() {
return Format;
}
public void setFormat(String format) {
Format
= format;
}

}
VoiceMessage

图片消息

java开发微信公众号3java开发微信公众号3
public class ImageMessage extends BaseMessage{
//图片链接
private String PicUrl;

public String getPicUrl() {
return PicUrl;
}

public void setPicUrl(String picUrl) {
PicUrl
= picUrl;
}
}
ImageMessage