mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-05-04 04:37:46 +08:00
根据java命名规范重新命名字段
This commit is contained in:
parent
49721a979a
commit
5b18c1419c
@ -38,7 +38,7 @@ wxService.setWxConfigStorage(config);
|
||||
|
||||
// 用户的openid在下面地址获得
|
||||
// https://mp.weixin.qq.com/debug/cgi-bin/apiinfo?t=index&type=用户管理&form=获取关注者列表接口%20/user/get
|
||||
String openid = ...;
|
||||
WxCustomMessage message = WxCustomMessage.TEXT().toUser(openid).content("Hello World").build();
|
||||
String openId = ...;
|
||||
WxCustomMessage message = WxCustomMessage.TEXT().toUser(openId).content("Hello World").build();
|
||||
wxService.customMessageSend(message);
|
||||
```
|
||||
|
@ -17,7 +17,7 @@ public class WxInMemoryConfigStorage implements WxConfigStorage {
|
||||
protected int expiresIn;
|
||||
|
||||
public void updateAccessToken(WxAccessToken accessToken) {
|
||||
updateAccessToken(accessToken.getAccess_token(), accessToken.getExpires_in());
|
||||
updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn());
|
||||
}
|
||||
|
||||
public void updateAccessToken(String accessToken, int expiresIn) {
|
||||
|
@ -4,8 +4,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@ -86,11 +84,11 @@ public class WxServiceImpl implements WxService {
|
||||
CloseableHttpResponse response = httpclient.execute(httpGet);
|
||||
String resultContent = new BasicResponseHandler().handleResponse(response);
|
||||
WxError error = WxError.fromJson(resultContent);
|
||||
if (error.getErrcode() != 0) {
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
}
|
||||
WxAccessToken accessToken = WxAccessToken.fromJson(resultContent);
|
||||
wxConfigStorage.updateAccessToken(accessToken.getAccess_token(), accessToken.getExpires_in());
|
||||
wxConfigStorage.updateAccessToken(accessToken.getAccessToken(), accessToken.getExpiresIn());
|
||||
} catch (ClientProtocolException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
@ -133,7 +131,7 @@ public class WxServiceImpl implements WxService {
|
||||
return WxMenu.fromJson(resultContent);
|
||||
} catch (WxErrorException e) {
|
||||
// 46003 不存在的菜单数据
|
||||
if (e.getError().getErrcode() == 46003) {
|
||||
if (e.getError().getErrorCode() == 46003) {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
@ -316,14 +314,14 @@ public class WxServiceImpl implements WxService {
|
||||
* 40001 获取access_token时AppSecret错误,或者access_token无效
|
||||
* 42001 access_token超时
|
||||
*/
|
||||
if (error.getErrcode() == 42001 || error.getErrcode() == 40001) {
|
||||
if (error.getErrorCode() == 42001 || error.getErrorCode() == 40001) {
|
||||
accessTokenRefresh();
|
||||
return execute(executor, uri, data);
|
||||
}
|
||||
/**
|
||||
* -1 系统繁忙, 1000ms后重试
|
||||
*/
|
||||
if (error.getErrcode() == -1) {
|
||||
if (error.getErrorCode() == -1) {
|
||||
if(retryTimes.get() == null) {
|
||||
retryTimes.set(0);
|
||||
}
|
||||
@ -341,7 +339,7 @@ public class WxServiceImpl implements WxService {
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
}
|
||||
if (error.getErrcode() != 0) {
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
}
|
||||
return null;
|
||||
|
@ -4,24 +4,24 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
|
||||
public class WxAccessToken {
|
||||
|
||||
private String access_token;
|
||||
private String accessToken;
|
||||
|
||||
private int expires_in;
|
||||
private int expiresIn;
|
||||
|
||||
public String getAccess_token() {
|
||||
return access_token;
|
||||
public String getAccessToken() {
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccess_token(String access_token) {
|
||||
this.access_token = access_token;
|
||||
public void setAccessToken(String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
public int getExpires_in() {
|
||||
return expires_in;
|
||||
public int getExpiresIn() {
|
||||
return expiresIn;
|
||||
}
|
||||
|
||||
public void setExpires_in(int expires_in) {
|
||||
this.expires_in = expires_in;
|
||||
public void setExpiresIn(int expiresIn) {
|
||||
this.expiresIn = expiresIn;
|
||||
}
|
||||
|
||||
public static WxAccessToken fromJson(String json) {
|
||||
|
@ -19,25 +19,25 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
*/
|
||||
public class WxCustomMessage {
|
||||
|
||||
private String touser;
|
||||
private String msgtype;
|
||||
private String toUser;
|
||||
private String msgType;
|
||||
private String content;
|
||||
private String media_id;
|
||||
private String thumb_media_id;
|
||||
private String mediaId;
|
||||
private String thumbMediaId;
|
||||
private String title;
|
||||
private String description;
|
||||
private String musicurl;
|
||||
private String hqmusicurl;
|
||||
private String musicUrl;
|
||||
private String hqMusicUrl;
|
||||
private List<WxArticle> articles = new ArrayList<WxArticle>();
|
||||
|
||||
public String getTouser() {
|
||||
return touser;
|
||||
public String getToUser() {
|
||||
return toUser;
|
||||
}
|
||||
public void setTouser(String touser) {
|
||||
this.touser = touser;
|
||||
public void setToUser(String toUser) {
|
||||
this.toUser = toUser;
|
||||
}
|
||||
public String getMsgtype() {
|
||||
return msgtype;
|
||||
public String getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,10 +50,10 @@ public class WxCustomMessage {
|
||||
* {@link WxConsts#CUSTOM_MSG_VIDEO}
|
||||
* {@link WxConsts#CUSTOM_MSG_NEWS}
|
||||
* </pre>
|
||||
* @param msgtype
|
||||
* @param msgType
|
||||
*/
|
||||
public void setMsgtype(String msgtype) {
|
||||
this.msgtype = msgtype;
|
||||
public void setMsgType(String msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
public String getContent() {
|
||||
return content;
|
||||
@ -61,17 +61,17 @@ public class WxCustomMessage {
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
public String getMedia_id() {
|
||||
return media_id;
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
public void setMedia_id(String media_id) {
|
||||
this.media_id = media_id;
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
public String getThumb_media_id() {
|
||||
return thumb_media_id;
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
public void setThumb_media_id(String thumb_media_id) {
|
||||
this.thumb_media_id = thumb_media_id;
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
@ -85,17 +85,17 @@ public class WxCustomMessage {
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
public String getMusicurl() {
|
||||
return musicurl;
|
||||
public String getMusicUrl() {
|
||||
return musicUrl;
|
||||
}
|
||||
public void setMusicurl(String musicurl) {
|
||||
this.musicurl = musicurl;
|
||||
public void setMusicUrl(String musicUrl) {
|
||||
this.musicUrl = musicUrl;
|
||||
}
|
||||
public String getHqmusicurl() {
|
||||
return hqmusicurl;
|
||||
public String getHqMusicUrl() {
|
||||
return hqMusicUrl;
|
||||
}
|
||||
public void setHqmusicurl(String hqmusicurl) {
|
||||
this.hqmusicurl = hqmusicurl;
|
||||
public void setHqMusicUrl(String hqMusicUrl) {
|
||||
this.hqMusicUrl = hqMusicUrl;
|
||||
}
|
||||
public List<WxArticle> getArticles() {
|
||||
return articles;
|
||||
@ -113,7 +113,7 @@ public class WxCustomMessage {
|
||||
private String title;
|
||||
private String description;
|
||||
private String url;
|
||||
private String picurl;
|
||||
private String picUrl;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
@ -133,11 +133,11 @@ public class WxCustomMessage {
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
public String getPicurl() {
|
||||
return picurl;
|
||||
public String getPicUrl() {
|
||||
return picUrl;
|
||||
}
|
||||
public void setPicurl(String picurl) {
|
||||
this.picurl = picurl;
|
||||
public void setPicUrl(String picUrl) {
|
||||
this.picUrl = picUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
*/
|
||||
public class WxMassGroupMessage {
|
||||
|
||||
private long group_id;
|
||||
private long groupId;
|
||||
private String msgtype;
|
||||
private String content;
|
||||
private String media_id;
|
||||
private String mediaId;
|
||||
|
||||
public WxMassGroupMessage() {
|
||||
super();
|
||||
@ -47,24 +47,24 @@ public class WxMassGroupMessage {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getMedia_id() {
|
||||
return media_id;
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMedia_id(String media_id) {
|
||||
this.media_id = media_id;
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.INSTANCE.create().toJson(this);
|
||||
}
|
||||
|
||||
public long getGroup_id() {
|
||||
return group_id;
|
||||
public long getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroup_id(long group_id) {
|
||||
this.group_id = group_id;
|
||||
public void setGroupId(long groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,13 +29,13 @@ public class WxMassNews {
|
||||
/**
|
||||
* <pre>
|
||||
* 群发图文消息article
|
||||
* 1. thumb_media_id (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得
|
||||
* 1. thumbMediaId (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得
|
||||
* 2. author 图文消息的作者
|
||||
* 3. title (必填) 图文消息的标题
|
||||
* 4. content_source_url 在图文消息页面点击“阅读原文”后的页面链接
|
||||
* 4. contentSourceUrl 在图文消息页面点击“阅读原文”后的页面链接
|
||||
* 5. content (必填) 图文消息页面的内容,支持HTML标签
|
||||
* 6. digest 图文消息的描述
|
||||
* 7, show_cover_pic 是否显示封面,true为显示,false为不显示
|
||||
* 7, showCoverPic 是否显示封面,true为显示,false为不显示
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
@ -44,7 +44,7 @@ public class WxMassNews {
|
||||
/**
|
||||
* (必填) 图文消息缩略图的media_id,可以在基础支持-上传多媒体文件接口中获得
|
||||
*/
|
||||
private String thumb_media_id;
|
||||
private String thumbMediaId;
|
||||
/**
|
||||
* 图文消息的作者
|
||||
*/
|
||||
@ -56,7 +56,7 @@ public class WxMassNews {
|
||||
/**
|
||||
* 在图文消息页面点击“阅读原文”后的页面链接
|
||||
*/
|
||||
private String content_source_url;
|
||||
private String contentSourceUrl;
|
||||
/**
|
||||
* (必填) 图文消息页面的内容,支持HTML标签
|
||||
*/
|
||||
@ -68,13 +68,13 @@ public class WxMassNews {
|
||||
/**
|
||||
* 是否显示封面,true为显示,false为不显示
|
||||
*/
|
||||
private boolean show_cover_pic;
|
||||
private boolean showCoverPic;
|
||||
|
||||
public String getThumb_media_id() {
|
||||
return thumb_media_id;
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
public void setThumb_media_id(String thumb_media_id) {
|
||||
this.thumb_media_id = thumb_media_id;
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
@ -88,11 +88,11 @@ public class WxMassNews {
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public String getContent_source_url() {
|
||||
return content_source_url;
|
||||
public String getContentSourceUrl() {
|
||||
return contentSourceUrl;
|
||||
}
|
||||
public void setContent_source_url(String content_source_url) {
|
||||
this.content_source_url = content_source_url;
|
||||
public void setContentSourceUrl(String contentSourceUrl) {
|
||||
this.contentSourceUrl = contentSourceUrl;
|
||||
}
|
||||
public String getContent() {
|
||||
return content;
|
||||
@ -106,11 +106,11 @@ public class WxMassNews {
|
||||
public void setDigest(String digest) {
|
||||
this.digest = digest;
|
||||
}
|
||||
public boolean isShow_cover_pic() {
|
||||
return show_cover_pic;
|
||||
public boolean isShowCoverPic() {
|
||||
return showCoverPic;
|
||||
}
|
||||
public void setShow_cover_pic(boolean show_cover_pic) {
|
||||
this.show_cover_pic = show_cover_pic;
|
||||
public void setShowCoverPic(boolean showCoverPic) {
|
||||
this.showCoverPic = showCoverPic;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,17 +12,17 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
*/
|
||||
public class WxMassOpenIdsMessage {
|
||||
|
||||
private List<String> touser = new ArrayList<String>();
|
||||
private String msgtype;
|
||||
private List<String> toUsers = new ArrayList<String>();
|
||||
private String msgType;
|
||||
private String content;
|
||||
private String media_id;
|
||||
private String mediaId;
|
||||
|
||||
public WxMassOpenIdsMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
public String getMsgtype() {
|
||||
return msgtype;
|
||||
public String getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,10 +35,10 @@ public class WxMassOpenIdsMessage {
|
||||
* {@link me.chanjar.weixin.api.WxConsts#MASS_MSG_VOICE}
|
||||
* 如果msgtype和media_id不匹配的话,会返回系统繁忙的错误
|
||||
* </pre>
|
||||
* @param msgtype
|
||||
* @param msgType
|
||||
*/
|
||||
public void setMsgtype(String msgtype) {
|
||||
this.msgtype = msgtype;
|
||||
public void setMsgType(String msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
@ -49,12 +49,12 @@ public class WxMassOpenIdsMessage {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getMedia_id() {
|
||||
return media_id;
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMedia_id(String media_id) {
|
||||
this.media_id = media_id;
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
@ -65,8 +65,8 @@ public class WxMassOpenIdsMessage {
|
||||
* OpenId列表,最多支持10,000个
|
||||
* @return
|
||||
*/
|
||||
public List<String> getTouser() {
|
||||
return touser;
|
||||
public List<String> getToUsers() {
|
||||
return toUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,6 +74,6 @@ public class WxMassOpenIdsMessage {
|
||||
* @param openId
|
||||
*/
|
||||
public void addUser(String openId) {
|
||||
this.touser.add(openId);
|
||||
this.toUsers.add(openId);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
*/
|
||||
public class WxMassVideo {
|
||||
|
||||
private String media_id;
|
||||
private String mediaId;
|
||||
private String title;
|
||||
private String description;
|
||||
|
||||
@ -29,12 +29,12 @@ public class WxMassVideo {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getMedia_id() {
|
||||
return media_id;
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMedia_id(String media_id) {
|
||||
this.media_id = media_id;
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
|
@ -14,14 +14,14 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
*/
|
||||
public class WxMenu {
|
||||
|
||||
private List<WxMenuButton> button = new ArrayList<WxMenuButton>();
|
||||
private List<WxMenuButton> buttons = new ArrayList<WxMenuButton>();
|
||||
|
||||
public List<WxMenuButton> getButton() {
|
||||
return button;
|
||||
public List<WxMenuButton> getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void setButton(List<WxMenuButton> button) {
|
||||
this.button = button;
|
||||
public void setButtons(List<WxMenuButton> buttons) {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
@ -43,7 +43,7 @@ public class WxMenu {
|
||||
private String key;
|
||||
private String url;
|
||||
|
||||
private List<WxMenuButton> sub_button = new ArrayList<WxMenuButton>();
|
||||
private List<WxMenuButton> subButtons = new ArrayList<WxMenuButton>();
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
@ -77,12 +77,12 @@ public class WxMenu {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public List<WxMenuButton> getSub_button() {
|
||||
return sub_button;
|
||||
public List<WxMenuButton> getSubButtons() {
|
||||
return subButtons;
|
||||
}
|
||||
|
||||
public void setSub_button(List<WxMenuButton> sub_button) {
|
||||
this.sub_button = sub_button;
|
||||
public void setSubButtons(List<WxMenuButton> subButtons) {
|
||||
this.subButtons = subButtons;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,91 +36,91 @@ public class WxXmlMessage {
|
||||
|
||||
@XmlElement(name = "ToUserName")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String ToUserName;
|
||||
private String toUserName;
|
||||
|
||||
@XmlElement(name = "FromUserName")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String FromUserName;
|
||||
private String fromUserName;
|
||||
|
||||
@XmlElement(name = "CreateTime")
|
||||
private Long CreateTime;
|
||||
private Long createTime;
|
||||
|
||||
@XmlElement(name = "MsgType")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String MsgType;
|
||||
private String msgType;
|
||||
|
||||
@XmlElement(name = "Content")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Content;
|
||||
private String content;
|
||||
|
||||
@XmlElement(name = "MsgId")
|
||||
private Long MsgId;
|
||||
private Long msgId;
|
||||
|
||||
@XmlElement(name = "PicUrl")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String PicUrl;
|
||||
private String picUrl;
|
||||
|
||||
@XmlElement(name = "MediaId")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String MediaId;
|
||||
private String mediaId;
|
||||
|
||||
@XmlElement(name = "Format")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Format;
|
||||
private String format;
|
||||
|
||||
@XmlElement(name = "ThumbMediaId")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String ThumbMediaId;
|
||||
private String thumbMediaId;
|
||||
|
||||
@XmlElement(name = "Location_X")
|
||||
private Double Location_X;
|
||||
private Double locationX;
|
||||
|
||||
@XmlElement(name = "Location_Y")
|
||||
private Double Location_Y;
|
||||
private Double locationY;
|
||||
|
||||
@XmlElement(name = "Scale")
|
||||
private Double Scale;
|
||||
private Double scale;
|
||||
|
||||
@XmlElement(name = "Label")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Label;
|
||||
private String label;
|
||||
|
||||
@XmlElement(name = "Title")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Title;
|
||||
private String title;
|
||||
|
||||
@XmlElement(name = "Description")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Description;
|
||||
private String description;
|
||||
|
||||
@XmlElement(name = "Url")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Url;
|
||||
private String url;
|
||||
|
||||
@XmlElement(name = "Event")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Event;
|
||||
private String event;
|
||||
|
||||
@XmlElement(name = "EventKey")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String EventKey;
|
||||
private String eventKey;
|
||||
|
||||
@XmlElement(name = "Ticket")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Ticket;
|
||||
private String ticket;
|
||||
|
||||
@XmlElement(name = "Latitude")
|
||||
private Double Latitude;
|
||||
private Double latitude;
|
||||
|
||||
@XmlElement(name = "Longitude")
|
||||
private Double Longitude;
|
||||
private Double longitude;
|
||||
|
||||
@XmlElement(name = "Precision")
|
||||
private Double Precision;
|
||||
private Double precision;
|
||||
|
||||
@XmlElement(name = "Recognition")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Recognition;
|
||||
private String recognition;
|
||||
|
||||
///////////////////////////////////////
|
||||
// 群发消息返回的结果
|
||||
@ -130,47 +130,51 @@ public class WxXmlMessage {
|
||||
*/
|
||||
@XmlElement(name = "Status")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Status;
|
||||
private String status;
|
||||
/**
|
||||
* group_id下粉丝数;或者openid_list中的粉丝数
|
||||
*/
|
||||
private Integer TotalCount;
|
||||
@XmlElement(name = "TotalCount")
|
||||
private Integer totalCount;
|
||||
/**
|
||||
* 过滤(过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,FilterCount = SentCount + ErrorCount
|
||||
* 过滤(过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,filterCount = sentCount + errorCount
|
||||
*/
|
||||
private Integer FilterCount;
|
||||
@XmlElement(name = "FilterCount")
|
||||
private Integer filterCount;
|
||||
/**
|
||||
* 发送成功的粉丝数
|
||||
*/
|
||||
private Integer SentCount;
|
||||
@XmlElement(name = "SentCount")
|
||||
private Integer sentCount;
|
||||
/**
|
||||
* 发送失败的粉丝数
|
||||
*/
|
||||
private Integer ErrorCount;
|
||||
@XmlElement(name = "ErrorCount")
|
||||
private Integer errorCount;
|
||||
|
||||
@XmlElement(name = "ScanCodeInfo")
|
||||
private ScanCodeInfo ScanCodeInfo = new ScanCodeInfo();
|
||||
private ScanCodeInfo scanCodeInfo = new ScanCodeInfo();
|
||||
|
||||
@XmlElement(name = "SendPicsInfo")
|
||||
private SendPicsInfo SendPicsInfo = new SendPicsInfo();
|
||||
private SendPicsInfo sendPicsInfo = new SendPicsInfo();
|
||||
|
||||
@XmlElement(name = "SendLocationInfo")
|
||||
private SendLocationInfo SendLocationInfo = new SendLocationInfo();
|
||||
private SendLocationInfo sendLocationInfo = new SendLocationInfo();
|
||||
|
||||
public String getToUserName() {
|
||||
return ToUserName;
|
||||
return toUserName;
|
||||
}
|
||||
|
||||
public void setToUserName(String toUserName) {
|
||||
ToUserName = toUserName;
|
||||
this.toUserName = toUserName;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return CreateTime;
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
CreateTime = createTime;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +192,7 @@ public class WxXmlMessage {
|
||||
* @return
|
||||
*/
|
||||
public String getMsgType() {
|
||||
return MsgType;
|
||||
return msgType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -205,175 +209,175 @@ public class WxXmlMessage {
|
||||
* @param msgType
|
||||
*/
|
||||
public void setMsgType(String msgType) {
|
||||
MsgType = msgType;
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return Content;
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
Content = content;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Long getMsgId() {
|
||||
return MsgId;
|
||||
return msgId;
|
||||
}
|
||||
|
||||
public void setMsgId(Long msgId) {
|
||||
MsgId = msgId;
|
||||
this.msgId = msgId;
|
||||
}
|
||||
|
||||
public String getPicUrl() {
|
||||
return PicUrl;
|
||||
return picUrl;
|
||||
}
|
||||
|
||||
public void setPicUrl(String picUrl) {
|
||||
PicUrl = picUrl;
|
||||
this.picUrl = picUrl;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return MediaId;
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
MediaId = mediaId;
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return Format;
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
Format = format;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return ThumbMediaId;
|
||||
return thumbMediaId;
|
||||
}
|
||||
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
ThumbMediaId = thumbMediaId;
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
|
||||
public Double getLocation_X() {
|
||||
return Location_X;
|
||||
public Double getLocationX() {
|
||||
return locationX;
|
||||
}
|
||||
|
||||
public void setLocation_X(Double location_X) {
|
||||
Location_X = location_X;
|
||||
public void setLocationX(Double locationX) {
|
||||
this.locationX = locationX;
|
||||
}
|
||||
|
||||
public Double getLocation_Y() {
|
||||
return Location_Y;
|
||||
public Double getLocationY() {
|
||||
return locationY;
|
||||
}
|
||||
|
||||
public void setLocation_Y(Double location_Y) {
|
||||
Location_Y = location_Y;
|
||||
public void setLocationY(Double locationY) {
|
||||
this.locationY = locationY;
|
||||
}
|
||||
|
||||
public Double getScale() {
|
||||
return Scale;
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(Double scale) {
|
||||
Scale = scale;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return Label;
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
Label = label;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return Title;
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
Title = title;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return Description;
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
Description = description;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return Url;
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
Url = url;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getEvent() {
|
||||
return Event;
|
||||
return event;
|
||||
}
|
||||
|
||||
public void setEvent(String event) {
|
||||
Event = event;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public String getEventKey() {
|
||||
return EventKey;
|
||||
return eventKey;
|
||||
}
|
||||
|
||||
public void setEventKey(String eventKey) {
|
||||
EventKey = eventKey;
|
||||
this.eventKey = eventKey;
|
||||
}
|
||||
|
||||
public String getTicket() {
|
||||
return Ticket;
|
||||
return ticket;
|
||||
}
|
||||
|
||||
public void setTicket(String ticket) {
|
||||
Ticket = ticket;
|
||||
this.ticket = ticket;
|
||||
}
|
||||
|
||||
public Double getLatitude() {
|
||||
return Latitude;
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(Double latitude) {
|
||||
Latitude = latitude;
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public Double getLongitude() {
|
||||
return Longitude;
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(Double longitude) {
|
||||
Longitude = longitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public Double getPrecision() {
|
||||
return Precision;
|
||||
return precision;
|
||||
}
|
||||
|
||||
public void setPrecision(Double precision) {
|
||||
Precision = precision;
|
||||
this.precision = precision;
|
||||
}
|
||||
|
||||
public String getRecognition() {
|
||||
return Recognition;
|
||||
return recognition;
|
||||
}
|
||||
|
||||
public void setRecognition(String recognition) {
|
||||
Recognition = recognition;
|
||||
this.recognition = recognition;
|
||||
}
|
||||
|
||||
public String getFromUserName() {
|
||||
return FromUserName;
|
||||
return fromUserName;
|
||||
}
|
||||
|
||||
public void setFromUserName(String fromUserName) {
|
||||
FromUserName = fromUserName;
|
||||
this.fromUserName = fromUserName;
|
||||
}
|
||||
|
||||
public static WxXmlMessage fromXml(String xml) {
|
||||
@ -423,67 +427,67 @@ public class WxXmlMessage {
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return Status;
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
Status = status;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getTotalCount() {
|
||||
return TotalCount;
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public void setTotalCount(Integer totalCount) {
|
||||
TotalCount = totalCount;
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public Integer getFilterCount() {
|
||||
return FilterCount;
|
||||
return filterCount;
|
||||
}
|
||||
|
||||
public void setFilterCount(Integer filterCount) {
|
||||
FilterCount = filterCount;
|
||||
this.filterCount = filterCount;
|
||||
}
|
||||
|
||||
public Integer getSentCount() {
|
||||
return SentCount;
|
||||
return sentCount;
|
||||
}
|
||||
|
||||
public void setSentCount(Integer sentCount) {
|
||||
SentCount = sentCount;
|
||||
this.sentCount = sentCount;
|
||||
}
|
||||
|
||||
public Integer getErrorCount() {
|
||||
return ErrorCount;
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
public void setErrorCount(Integer errorCount) {
|
||||
ErrorCount = errorCount;
|
||||
this.errorCount = errorCount;
|
||||
}
|
||||
|
||||
public WxXmlMessage.ScanCodeInfo getScanCodeInfo() {
|
||||
return ScanCodeInfo;
|
||||
return scanCodeInfo;
|
||||
}
|
||||
|
||||
public void setScanCodeInfo(WxXmlMessage.ScanCodeInfo scanCodeInfo) {
|
||||
ScanCodeInfo = scanCodeInfo;
|
||||
this.scanCodeInfo = scanCodeInfo;
|
||||
}
|
||||
|
||||
public WxXmlMessage.SendPicsInfo getSendPicsInfo() {
|
||||
return SendPicsInfo;
|
||||
return sendPicsInfo;
|
||||
}
|
||||
|
||||
public void setSendPicsInfo(WxXmlMessage.SendPicsInfo sendPicsInfo) {
|
||||
SendPicsInfo = sendPicsInfo;
|
||||
this.sendPicsInfo = sendPicsInfo;
|
||||
}
|
||||
|
||||
public WxXmlMessage.SendLocationInfo getSendLocationInfo() {
|
||||
return SendLocationInfo;
|
||||
return sendLocationInfo;
|
||||
}
|
||||
|
||||
public void setSendLocationInfo(WxXmlMessage.SendLocationInfo sendLocationInfo) {
|
||||
SendLocationInfo = sendLocationInfo;
|
||||
this.sendLocationInfo = sendLocationInfo;
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "ScanCodeInfo")
|
||||
@ -492,11 +496,11 @@ public class WxXmlMessage {
|
||||
|
||||
@XmlElement(name = "ScanType")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String ScanType;
|
||||
private String scanType;
|
||||
|
||||
@XmlElement(name = "ScanResult")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String ScanResult;
|
||||
private String scanResult;
|
||||
|
||||
/**
|
||||
* 扫描类型,一般是qrcode
|
||||
@ -504,11 +508,11 @@ public class WxXmlMessage {
|
||||
*/
|
||||
public String getScanType() {
|
||||
|
||||
return ScanType;
|
||||
return scanType;
|
||||
}
|
||||
|
||||
public void setScanType(String scanType) {
|
||||
ScanType = scanType;
|
||||
this.scanType = scanType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -516,11 +520,11 @@ public class WxXmlMessage {
|
||||
* @return
|
||||
*/
|
||||
public String getScanResult() {
|
||||
return ScanResult;
|
||||
return scanResult;
|
||||
}
|
||||
|
||||
public void setScanResult(String scanResult) {
|
||||
ScanResult = scanResult;
|
||||
this.scanResult = scanResult;
|
||||
}
|
||||
|
||||
}
|
||||
@ -529,22 +533,23 @@ public class WxXmlMessage {
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public static class SendPicsInfo {
|
||||
|
||||
private Long Count;
|
||||
@XmlElement(name = "Count")
|
||||
private Long count;
|
||||
|
||||
@XmlElementWrapper(name="PicList")
|
||||
@XmlElement(name = "item")
|
||||
protected final List<Item> PicList = new ArrayList<Item>();
|
||||
protected final List<Item> picList = new ArrayList<Item>();
|
||||
|
||||
public Long getCount() {
|
||||
return Count;
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Long count) {
|
||||
Count = count;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public List<Item> getPicList() {
|
||||
return PicList;
|
||||
return picList;
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "item")
|
||||
@ -572,62 +577,62 @@ public class WxXmlMessage {
|
||||
|
||||
@XmlElement(name = "Location_X")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Location_X;
|
||||
private String locationX;
|
||||
|
||||
@XmlElement(name = "Location_Y")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Location_Y;
|
||||
private String locationY;
|
||||
|
||||
@XmlElement(name = "Scale")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Scale;
|
||||
private String scale;
|
||||
|
||||
@XmlElement(name = "Label")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Label;
|
||||
private String label;
|
||||
|
||||
@XmlElement(name = "Poiname")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Poiname;
|
||||
private String poiname;
|
||||
|
||||
public String getLocation_X() {
|
||||
return Location_X;
|
||||
public String getLocationX() {
|
||||
return locationX;
|
||||
}
|
||||
|
||||
public void setLocation_X(String location_X) {
|
||||
Location_X = location_X;
|
||||
public void setLocationX(String locationX) {
|
||||
this.locationX = locationX;
|
||||
}
|
||||
|
||||
public String getLocation_Y() {
|
||||
return Location_Y;
|
||||
public String getLocationY() {
|
||||
return locationY;
|
||||
}
|
||||
|
||||
public void setLocation_Y(String location_Y) {
|
||||
Location_Y = location_Y;
|
||||
public void setLocationY(String locationY) {
|
||||
this.locationY = locationY;
|
||||
}
|
||||
|
||||
public String getScale() {
|
||||
return Scale;
|
||||
return scale;
|
||||
}
|
||||
|
||||
public void setScale(String scale) {
|
||||
Scale = scale;
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return Label;
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
Label = label;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getPoiname() {
|
||||
return Poiname;
|
||||
return poiname;
|
||||
}
|
||||
|
||||
public void setPoiname(String poiname) {
|
||||
Poiname = poiname;
|
||||
this.poiname = poiname;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,18 +15,18 @@ public class WxXmlOutImageMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name="Image")
|
||||
@XmlJavaTypeAdapter(MediaIdMarshaller.class)
|
||||
private String MediaId;
|
||||
private String mediaId;
|
||||
|
||||
public WxXmlOutImageMessage() {
|
||||
this.MsgType = WxConsts.XML_MSG_IMAGE;
|
||||
this.msgType = WxConsts.XML_MSG_IMAGE;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return MediaId;
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
MediaId = mediaId;
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,49 +24,49 @@ public class WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name="ToUserName")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
protected String ToUserName;
|
||||
protected String toUserName;
|
||||
|
||||
@XmlElement(name="FromUserName")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
protected String FromUserName;
|
||||
protected String fromUserName;
|
||||
|
||||
@XmlElement(name="CreateTime")
|
||||
protected Long CreateTime;
|
||||
protected Long createTime;
|
||||
|
||||
@XmlElement(name="MsgType")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
protected String MsgType;
|
||||
protected String msgType;
|
||||
|
||||
public String getToUserName() {
|
||||
return ToUserName;
|
||||
return toUserName;
|
||||
}
|
||||
|
||||
public void setToUserName(String toUserName) {
|
||||
ToUserName = toUserName;
|
||||
this.toUserName = toUserName;
|
||||
}
|
||||
|
||||
public String getFromUserName() {
|
||||
return FromUserName;
|
||||
return fromUserName;
|
||||
}
|
||||
|
||||
public void setFromUserName(String fromUserName) {
|
||||
FromUserName = fromUserName;
|
||||
this.fromUserName = fromUserName;
|
||||
}
|
||||
|
||||
public Long getCreateTime() {
|
||||
return CreateTime;
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Long createTime) {
|
||||
CreateTime = createTime;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getMsgType() {
|
||||
return MsgType;
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public void setMsgType(String msgType) {
|
||||
MsgType = msgType;
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public String toXml() {
|
||||
|
@ -18,27 +18,27 @@ import me.chanjar.weixin.util.xml.AdapterCDATA;
|
||||
public class WxXmlOutMewsMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name = "ArticleCount")
|
||||
protected int ArticleCount;
|
||||
protected int articleCount;
|
||||
|
||||
@XmlElementWrapper(name="Articles")
|
||||
@XmlElement(name = "Item")
|
||||
protected final List<Item> Articles = new ArrayList<Item>();
|
||||
protected final List<Item> articles = new ArrayList<Item>();
|
||||
|
||||
public WxXmlOutMewsMessage() {
|
||||
this.MsgType = WxConsts.XML_MSG_NEWS;
|
||||
this.msgType = WxConsts.XML_MSG_NEWS;
|
||||
}
|
||||
|
||||
public int getArticleCount() {
|
||||
return ArticleCount;
|
||||
return articleCount;
|
||||
}
|
||||
|
||||
public void addArticle(Item item) {
|
||||
this.Articles.add(item);
|
||||
this.ArticleCount = this.Articles.size();
|
||||
this.articles.add(item);
|
||||
this.articleCount = this.articles.size();
|
||||
}
|
||||
|
||||
public List<Item> getArticles() {
|
||||
return Articles;
|
||||
return articles;
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class WxXmlOutMusicMessage extends WxXmlOutMessage {
|
||||
protected final Music music = new Music();
|
||||
|
||||
public WxXmlOutMusicMessage() {
|
||||
this.MsgType = WxConsts.XML_MSG_MUSIC;
|
||||
this.msgType = WxConsts.XML_MSG_MUSIC;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
@ -52,12 +52,12 @@ public class WxXmlOutMusicMessage extends WxXmlOutMessage {
|
||||
music.setMusicUrl(musicUrl);
|
||||
}
|
||||
|
||||
public String getHQMusicUrl() {
|
||||
return music.getHQMusicUrl();
|
||||
public String getHqMusicUrl() {
|
||||
return music.getHqMusicUrl();
|
||||
}
|
||||
|
||||
public void setHQMusicUrl(String hQMusicUrl) {
|
||||
music.setHQMusicUrl(hQMusicUrl);
|
||||
public void setHqMusicUrl(String hqMusicUrl) {
|
||||
music.setHqMusicUrl(hqMusicUrl);
|
||||
}
|
||||
|
||||
@XmlRootElement(name = "Music")
|
||||
@ -66,62 +66,62 @@ public class WxXmlOutMusicMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name = "Title")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Title;
|
||||
private String title;
|
||||
|
||||
@XmlElement(name = "Description")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Description;
|
||||
private String description;
|
||||
|
||||
@XmlElement(name="ThumbMediaId")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String ThumbMediaId;
|
||||
private String thumbMediaId;
|
||||
|
||||
@XmlElement(name="MusicUrl")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String MusicUrl;
|
||||
private String musicUrl;
|
||||
|
||||
@XmlElement(name="HQMusicUrl")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String HQMusicUrl;
|
||||
private String hqMusicUrl;
|
||||
|
||||
public String getTitle() {
|
||||
return Title;
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
Title = title;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return Description;
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
Description = description;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getThumbMediaId() {
|
||||
return ThumbMediaId;
|
||||
return thumbMediaId;
|
||||
}
|
||||
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
ThumbMediaId = thumbMediaId;
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
|
||||
public String getMusicUrl() {
|
||||
return MusicUrl;
|
||||
return musicUrl;
|
||||
}
|
||||
|
||||
public void setMusicUrl(String musicUrl) {
|
||||
MusicUrl = musicUrl;
|
||||
this.musicUrl = musicUrl;
|
||||
}
|
||||
|
||||
public String getHQMusicUrl() {
|
||||
return HQMusicUrl;
|
||||
public String getHqMusicUrl() {
|
||||
return hqMusicUrl;
|
||||
}
|
||||
|
||||
public void setHQMusicUrl(String hQMusicUrl) {
|
||||
HQMusicUrl = hQMusicUrl;
|
||||
public void setHqMusicUrl(String hqMusicUrl) {
|
||||
this.hqMusicUrl = hqMusicUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ public class WxXmlOutTextMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name="Content")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Content;
|
||||
private String content;
|
||||
|
||||
public WxXmlOutTextMessage() {
|
||||
this.MsgType = WxConsts.XML_MSG_TEXT;
|
||||
this.msgType = WxConsts.XML_MSG_TEXT;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return Content;
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
Content = content;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class WxXmlOutVideoMessage extends WxXmlOutMessage {
|
||||
protected final Video video = new Video();
|
||||
|
||||
public WxXmlOutVideoMessage() {
|
||||
this.MsgType = WxConsts.XML_MSG_VIDEO;
|
||||
this.msgType = WxConsts.XML_MSG_VIDEO;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
@ -51,38 +51,38 @@ public class WxXmlOutVideoMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name = "MediaId")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String MediaId;
|
||||
private String mediaId;
|
||||
|
||||
@XmlElement(name = "Title")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Title;
|
||||
private String title;
|
||||
|
||||
@XmlElement(name = "Description")
|
||||
@XmlJavaTypeAdapter(AdapterCDATA.class)
|
||||
private String Description;
|
||||
private String description;
|
||||
|
||||
public String getMediaId() {
|
||||
return MediaId;
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
MediaId = mediaId;
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return Title;
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
Title = title;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return Description;
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
Description = description;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,18 +15,18 @@ public class WxXmlOutVoiceMessage extends WxXmlOutMessage {
|
||||
|
||||
@XmlElement(name="Voice")
|
||||
@XmlJavaTypeAdapter(MediaIdMarshaller.class)
|
||||
private String MediaId;
|
||||
private String mediaId;
|
||||
|
||||
public WxXmlOutVoiceMessage() {
|
||||
this.MsgType = WxConsts.XML_MSG_VOICE;
|
||||
this.msgType = WxConsts.XML_MSG_VOICE;
|
||||
}
|
||||
|
||||
public String getMediaId() {
|
||||
return MediaId;
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMediaId(String mediaId) {
|
||||
MediaId = mediaId;
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package me.chanjar.weixin.bean.custombuilder;
|
||||
import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
|
||||
public class BaseBuilder<T> {
|
||||
protected String msgtype;
|
||||
protected String msgType;
|
||||
protected String toUser;
|
||||
|
||||
public T toUser(String toUser) {
|
||||
@ -13,8 +13,8 @@ public class BaseBuilder<T> {
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = new WxCustomMessage();
|
||||
m.setMsgtype(this.msgtype);
|
||||
m.setTouser(this.toUser);
|
||||
m.setMsgType(this.msgType);
|
||||
m.setToUser(this.toUser);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
@ -6,26 +6,26 @@ import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
/**
|
||||
* 获得消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.IMAGE().media_id(...).touser(...).build();
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.IMAGE().mediaId(...).touser(...).build();
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class ImageBuilder extends BaseBuilder<ImageBuilder> {
|
||||
private String media_id;
|
||||
private String mediaId;
|
||||
|
||||
public ImageBuilder() {
|
||||
this.msgtype = WxConsts.CUSTOM_MSG_IMAGE;
|
||||
this.msgType = WxConsts.CUSTOM_MSG_IMAGE;
|
||||
}
|
||||
|
||||
public ImageBuilder mediaId(String media_id) {
|
||||
this.media_id = media_id;
|
||||
this.mediaId = media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setMedia_id(this.media_id);
|
||||
m.setMediaId(this.mediaId);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,10 @@ import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
* 音乐消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.MUSIC()
|
||||
* .musicurl(...)
|
||||
* .hqmusicurl(...)
|
||||
* .musicUrl(...)
|
||||
* .hqMusicUrl(...)
|
||||
* .title(...)
|
||||
* .thumb_media_id(..)
|
||||
* .thumbMediaId(..)
|
||||
* .description(..)
|
||||
* .touser(...)
|
||||
* .build();
|
||||
@ -19,21 +19,21 @@ import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
|
||||
private String title;
|
||||
private String description;
|
||||
private String thumb_media_id;
|
||||
private String musicurl;
|
||||
private String hqmusicurl;
|
||||
private String thumbMediaId;
|
||||
private String musicUrl;
|
||||
private String hqMusicUrl;
|
||||
|
||||
public MusicBuilder() {
|
||||
this.msgtype = WxConsts.CUSTOM_MSG_MUSIC;
|
||||
this.msgType = WxConsts.CUSTOM_MSG_MUSIC;
|
||||
}
|
||||
|
||||
public MusicBuilder musicUrl(String musicurl) {
|
||||
this.musicurl = musicurl;
|
||||
this.musicUrl = musicurl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder hqmusicUrl(String hqmusicurl) {
|
||||
this.hqmusicurl = hqmusicurl;
|
||||
public MusicBuilder hqMusicUrl(String hqMusicurl) {
|
||||
this.hqMusicUrl = hqMusicurl;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -48,17 +48,17 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder> {
|
||||
}
|
||||
|
||||
public MusicBuilder thumbMediaId(String thumb_media_id) {
|
||||
this.thumb_media_id = thumb_media_id;
|
||||
this.thumbMediaId = thumb_media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setMusicurl(this.musicurl);
|
||||
m.setHqmusicurl(this.hqmusicurl);
|
||||
m.setMusicUrl(this.musicUrl);
|
||||
m.setHqMusicUrl(this.hqMusicUrl);
|
||||
m.setTitle(title);
|
||||
m.setDescription(description);
|
||||
m.setThumb_media_id(thumb_media_id);
|
||||
m.setThumbMediaId(thumbMediaId);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public final class NewsBuilder extends BaseBuilder<NewsBuilder> {
|
||||
private List<WxCustomMessage.WxArticle> articles = new ArrayList<WxCustomMessage.WxArticle>();
|
||||
|
||||
public NewsBuilder() {
|
||||
this.msgtype = WxConsts.CUSTOM_MSG_NEWS;
|
||||
this.msgType = WxConsts.CUSTOM_MSG_NEWS;
|
||||
}
|
||||
|
||||
public NewsBuilder addArticle(WxCustomMessage.WxArticle article) {
|
||||
|
@ -15,7 +15,7 @@ public final class TextBuilder extends BaseBuilder<TextBuilder> {
|
||||
private String content;
|
||||
|
||||
public TextBuilder() {
|
||||
this.msgtype = WxConsts.CUSTOM_MSG_TEXT;
|
||||
this.msgType = WxConsts.CUSTOM_MSG_TEXT;
|
||||
}
|
||||
|
||||
public TextBuilder content(String content) {
|
||||
|
@ -7,9 +7,9 @@ import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
* 视频消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.VOICE()
|
||||
* .media_id(...)
|
||||
* .mediaId(...)
|
||||
* .title(...)
|
||||
* .thumb_media_id(..)
|
||||
* .thumbMediaId(..)
|
||||
* .description(..)
|
||||
* .touser(...)
|
||||
* .build();
|
||||
@ -18,17 +18,17 @@ import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
*
|
||||
*/
|
||||
public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
|
||||
private String media_id;
|
||||
private String mediaId;
|
||||
private String title;
|
||||
private String description;
|
||||
private String thumb_media_id;
|
||||
private String thumbMediaId;
|
||||
|
||||
public VideoBuilder() {
|
||||
this.msgtype = WxConsts.CUSTOM_MSG_VIDEO;
|
||||
this.msgType = WxConsts.CUSTOM_MSG_VIDEO;
|
||||
}
|
||||
|
||||
public VideoBuilder mediaId(String media_id) {
|
||||
this.media_id = media_id;
|
||||
public VideoBuilder mediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -43,16 +43,16 @@ public final class VideoBuilder extends BaseBuilder<VideoBuilder> {
|
||||
}
|
||||
|
||||
public VideoBuilder thumbMediaId(String thumb_media_id) {
|
||||
this.thumb_media_id = thumb_media_id;
|
||||
this.thumbMediaId = thumb_media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setMedia_id(this.media_id);
|
||||
m.setMediaId(this.mediaId);
|
||||
m.setTitle(title);
|
||||
m.setDescription(description);
|
||||
m.setThumb_media_id(thumb_media_id);
|
||||
m.setThumbMediaId(thumbMediaId);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
@ -6,26 +6,26 @@ import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
/**
|
||||
* 语音消息builder
|
||||
* <pre>
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.VOICE().media_id(...).touser(...).build();
|
||||
* 用法: WxCustomMessage m = WxCustomMessage.VOICE().mediaId(...).touser(...).build();
|
||||
* </pre>
|
||||
* @author chanjarster
|
||||
*
|
||||
*/
|
||||
public final class VoiceBuilder extends BaseBuilder<VoiceBuilder> {
|
||||
private String media_id;
|
||||
private String mediaId;
|
||||
|
||||
public VoiceBuilder() {
|
||||
this.msgtype = WxConsts.CUSTOM_MSG_VOICE;
|
||||
this.msgType = WxConsts.CUSTOM_MSG_VOICE;
|
||||
}
|
||||
|
||||
public VoiceBuilder mediaId(String media_id) {
|
||||
this.media_id = media_id;
|
||||
this.mediaId = media_id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxCustomMessage build() {
|
||||
WxCustomMessage m = super.build();
|
||||
m.setMedia_id(this.media_id);
|
||||
m.setMediaId(this.mediaId);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder, WxXmlOutMusicM
|
||||
|
||||
private String title;
|
||||
private String description;
|
||||
private String hQMusicUrl;
|
||||
private String hqMusicUrl;
|
||||
private String musicUrl;
|
||||
private String thumbMediaId;
|
||||
|
||||
@ -25,8 +25,8 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder, WxXmlOutMusicM
|
||||
return this;
|
||||
}
|
||||
|
||||
public MusicBuilder hqmusicUrl(String hQMusicUrl) {
|
||||
this.hQMusicUrl = hQMusicUrl;
|
||||
public MusicBuilder hqMusicUrl(String hqMusicUrl) {
|
||||
this.hqMusicUrl = hqMusicUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ public final class MusicBuilder extends BaseBuilder<MusicBuilder, WxXmlOutMusicM
|
||||
setCommon(m);
|
||||
m.setTitle(title);
|
||||
m.setDescription(description);
|
||||
m.setHQMusicUrl(hQMusicUrl);
|
||||
m.setHqMusicUrl(hqMusicUrl);
|
||||
m.setMusicUrl(musicUrl);
|
||||
m.setThumbMediaId(thumbMediaId);
|
||||
return m;
|
||||
|
@ -100,28 +100,28 @@ public class WxError {
|
||||
errMap.put(50001, "用户未授权该api");
|
||||
}
|
||||
|
||||
protected int errcode;
|
||||
protected int errorCode;
|
||||
|
||||
protected String errmsg;
|
||||
protected String errorMsg;
|
||||
|
||||
public int getErrcode() {
|
||||
return errcode;
|
||||
public int getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrcode(int errcode) {
|
||||
this.errcode = errcode;
|
||||
public void setErrorCode(int errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrmsg() {
|
||||
return errmsg;
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public void setErrmsg(String errmsg) {
|
||||
this.errmsg = errmsg;
|
||||
public void setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return errMap.get(errcode);
|
||||
return errMap.get(errorCode);
|
||||
}
|
||||
|
||||
public static WxError fromJson(String json) {
|
||||
@ -130,7 +130,7 @@ public class WxError {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "微信错误 errcode=" + errcode + ", errmsg=" + errmsg + ", description=" + getDescription();
|
||||
return "微信错误 errcode=" + errorCode + ", errmsg=" + errorMsg + ", description=" + getDescription();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,32 +15,32 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
*/
|
||||
public class WxMassSendResult {
|
||||
|
||||
private String errcode;
|
||||
private String errmsg;
|
||||
private String msg_id;
|
||||
private String errorCode;
|
||||
private String errorMsg;
|
||||
private String msgId;
|
||||
|
||||
public String getErrcode() {
|
||||
return errcode;
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrcode(String errcode) {
|
||||
this.errcode = errcode;
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public String getErrmsg() {
|
||||
return errmsg;
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
public void setErrmsg(String errmsg) {
|
||||
this.errmsg = errmsg;
|
||||
public void setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
}
|
||||
|
||||
public String getMsg_id() {
|
||||
return msg_id;
|
||||
public String getMsgId() {
|
||||
return msgId;
|
||||
}
|
||||
|
||||
public void setMsg_id(String msg_id) {
|
||||
this.msg_id = msg_id;
|
||||
public void setMsgId(String msgId) {
|
||||
this.msgId = msgId;
|
||||
}
|
||||
|
||||
public static WxMassSendResult fromJson(String json) {
|
||||
@ -49,7 +49,7 @@ public class WxMassSendResult {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxMassSendResult [errcode=" + errcode + ", errmsg=" + errmsg + ", msg_id=" + msg_id + "]";
|
||||
return "WxMassSendResult [errcode=" + errorCode + ", errmsg=" + errorMsg + ", msg_id=" + msgId + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
public class WxMassUploadResult {
|
||||
|
||||
private String type;
|
||||
private String media_id;
|
||||
private long created_at;
|
||||
private String mediaId;
|
||||
private long createdAt;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
@ -24,20 +24,20 @@ public class WxMassUploadResult {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMedia_id() {
|
||||
return media_id;
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMedia_id(String media_id) {
|
||||
this.media_id = media_id;
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public long getCreated_at() {
|
||||
return created_at;
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreated_at(long created_at) {
|
||||
this.created_at = created_at;
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public static WxMassUploadResult fromJson(String json) {
|
||||
@ -46,7 +46,7 @@ public class WxMassUploadResult {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxUploadResult [type=" + type + ", media_id=" + media_id + ", created_at=" + created_at + "]";
|
||||
return "WxUploadResult [type=" + type + ", media_id=" + mediaId + ", created_at=" + createdAt + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
public class WxMediaUploadResult {
|
||||
|
||||
private String type;
|
||||
private String media_id;
|
||||
private String thumb_media_id;
|
||||
private long created_at;
|
||||
private String mediaId;
|
||||
private String thumbMediaId;
|
||||
private long createdAt;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
@ -17,38 +17,38 @@ public class WxMediaUploadResult {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMedia_id() {
|
||||
return media_id;
|
||||
public String getMediaId() {
|
||||
return mediaId;
|
||||
}
|
||||
|
||||
public void setMedia_id(String media_id) {
|
||||
this.media_id = media_id;
|
||||
public void setMediaId(String mediaId) {
|
||||
this.mediaId = mediaId;
|
||||
}
|
||||
|
||||
public long getCreated_at() {
|
||||
return created_at;
|
||||
public long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreated_at(long created_at) {
|
||||
this.created_at = created_at;
|
||||
public void setCreatedAt(long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public static WxMediaUploadResult fromJson(String json) {
|
||||
return WxGsonBuilder.create().fromJson(json, WxMediaUploadResult.class);
|
||||
}
|
||||
|
||||
public String getThumb_media_id() {
|
||||
return thumb_media_id;
|
||||
public String getThumbMediaId() {
|
||||
return thumbMediaId;
|
||||
}
|
||||
|
||||
public void setThumb_media_id(String thumb_media_id) {
|
||||
this.thumb_media_id = thumb_media_id;
|
||||
public void setThumbMediaId(String thumbMediaId) {
|
||||
this.thumbMediaId = thumbMediaId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxUploadResult [type=" + type + ", media_id=" + media_id + ", thumb_media_id=" + thumb_media_id
|
||||
+ ", created_at=" + created_at + "]";
|
||||
return "WxUploadResult [type=" + type + ", media_id=" + mediaId + ", thumb_media_id=" + thumbMediaId
|
||||
+ ", created_at=" + createdAt + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,16 +10,16 @@ import me.chanjar.weixin.util.json.WxGsonBuilder;
|
||||
public class WxUser {
|
||||
|
||||
protected boolean subscribe;
|
||||
protected String openid;
|
||||
protected String openId;
|
||||
protected String nickname;
|
||||
protected String sex;
|
||||
protected String language;
|
||||
protected String city;
|
||||
protected String province;
|
||||
protected String country;
|
||||
protected String headimgurl;
|
||||
protected long subscribe_time;
|
||||
protected String unionid;
|
||||
protected String headImgUrl;
|
||||
protected long subscribeTime;
|
||||
protected String unionId;
|
||||
|
||||
public boolean isSubscribe() {
|
||||
return subscribe;
|
||||
@ -27,11 +27,11 @@ public class WxUser {
|
||||
public void setSubscribe(boolean subscribe) {
|
||||
this.subscribe = subscribe;
|
||||
}
|
||||
public String getOpenid() {
|
||||
return openid;
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
public void setOpenid(String openid) {
|
||||
this.openid = openid;
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
@ -69,23 +69,23 @@ public class WxUser {
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
public String getHeadimgurl() {
|
||||
return headimgurl;
|
||||
public String getHeadImgUrl() {
|
||||
return headImgUrl;
|
||||
}
|
||||
public void setHeadimgurl(String headimgurl) {
|
||||
this.headimgurl = headimgurl;
|
||||
public void setHeadImgUrl(String headImgUrl) {
|
||||
this.headImgUrl = headImgUrl;
|
||||
}
|
||||
public long getSubscribe_time() {
|
||||
return subscribe_time;
|
||||
public long getSubscribeTime() {
|
||||
return subscribeTime;
|
||||
}
|
||||
public void setSubscribe_time(long subscribe_time) {
|
||||
this.subscribe_time = subscribe_time;
|
||||
public void setSubscribeTime(long subscribeTime) {
|
||||
this.subscribeTime = subscribeTime;
|
||||
}
|
||||
public String getUnionid() {
|
||||
return unionid;
|
||||
public String getUnionId() {
|
||||
return unionId;
|
||||
}
|
||||
public void setUnionid(String unionid) {
|
||||
this.unionid = unionid;
|
||||
public void setUnionId(String unionId) {
|
||||
this.unionId = unionId;
|
||||
}
|
||||
|
||||
public static WxUser fromJson(String json) {
|
||||
|
@ -15,8 +15,8 @@ public class WxUserList {
|
||||
|
||||
protected int total = -1;
|
||||
protected int count = -1;
|
||||
protected List<String> openids = new ArrayList<String>();
|
||||
protected String next_openid;
|
||||
protected List<String> openIds = new ArrayList<String>();
|
||||
protected String nextOpenId;
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
@ -29,17 +29,17 @@ public class WxUserList {
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
public List<String> getOpenids() {
|
||||
return openids;
|
||||
public List<String> getOpenIds() {
|
||||
return openIds;
|
||||
}
|
||||
public void setOpenids(List<String> openids) {
|
||||
this.openids = openids;
|
||||
public void setOpenIds(List<String> openIds) {
|
||||
this.openIds = openIds;
|
||||
}
|
||||
public String getNext_openid() {
|
||||
return next_openid;
|
||||
public String getNextOpenId() {
|
||||
return nextOpenId;
|
||||
}
|
||||
public void setNext_openid(String next_openid) {
|
||||
this.next_openid = next_openid;
|
||||
public void setNextOpenId(String nextOpenId) {
|
||||
this.nextOpenId = nextOpenId;
|
||||
}
|
||||
|
||||
public static WxUserList fromJson(String json) {
|
||||
|
@ -35,7 +35,7 @@ public class MediaUploadRequestExecutor implements RequestExecutor<WxMediaUpload
|
||||
CloseableHttpResponse response = httpclient.execute(httpPost);
|
||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
||||
WxError error = WxError.fromJson(responseContent);
|
||||
if (error.getErrcode() != 0) {
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
}
|
||||
return WxMediaUploadResult.fromJson(responseContent);
|
||||
|
@ -28,7 +28,7 @@ public class SimpleGetRequestExecutor implements RequestExecutor<String, String>
|
||||
CloseableHttpResponse response = httpclient.execute(httpGet);
|
||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
||||
WxError error = WxError.fromJson(responseContent);
|
||||
if (error.getErrcode() != 0) {
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
}
|
||||
return responseContent;
|
||||
|
@ -27,7 +27,7 @@ public class SimplePostRequestExecutor implements RequestExecutor<String, String
|
||||
CloseableHttpResponse response = httpclient.execute(httpPost);
|
||||
String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response);
|
||||
WxError error = WxError.fromJson(responseContent);
|
||||
if (error.getErrcode() != 0) {
|
||||
if (error.getErrorCode() != 0) {
|
||||
throw new WxErrorException(error);
|
||||
}
|
||||
return responseContent;
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
|
||||
*
|
||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
|
||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
|
||||
* arose from modification of the original source, or other redistribution of this source
|
||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
|
||||
*/
|
||||
package me.chanjar.weixin.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.bean.WxAccessToken;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxAccessTokenAdapter implements JsonDeserializer<WxAccessToken> {
|
||||
|
||||
public WxAccessToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
WxAccessToken accessToken = new WxAccessToken();
|
||||
JsonObject accessTokenJsonObject = json.getAsJsonObject();
|
||||
|
||||
if (accessTokenJsonObject.get("access_token") != null && !accessTokenJsonObject.get("access_token").isJsonNull()) {
|
||||
accessToken.setAccessToken(GsonHelper.getAsString(accessTokenJsonObject.get("access_token")));
|
||||
}
|
||||
if (accessTokenJsonObject.get("expires_in") != null && !accessTokenJsonObject.get("expires_in").isJsonNull()) {
|
||||
accessToken.setExpiresIn(GsonHelper.getAsPrimitiveInt(accessTokenJsonObject.get("expires_in")));
|
||||
}
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
}
|
@ -28,54 +28,54 @@ public class WxCustomMessageGsonAdapter implements JsonSerializer<WxCustomMessag
|
||||
|
||||
public JsonElement serialize(WxCustomMessage message, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject messageJson = new JsonObject();
|
||||
messageJson.addProperty("touser", message.getTouser());
|
||||
messageJson.addProperty("msgtype", message.getMsgtype());
|
||||
messageJson.addProperty("touser", message.getToUser());
|
||||
messageJson.addProperty("msgtype", message.getMsgType());
|
||||
|
||||
if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgtype())) {
|
||||
if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) {
|
||||
JsonObject text = new JsonObject();
|
||||
text.addProperty("content", message.getContent());
|
||||
messageJson.add("text", text);
|
||||
}
|
||||
|
||||
if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgtype())) {
|
||||
if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) {
|
||||
JsonObject image = new JsonObject();
|
||||
image.addProperty("media_id", message.getMedia_id());
|
||||
image.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add("image", image);
|
||||
}
|
||||
|
||||
if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgtype())) {
|
||||
if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) {
|
||||
JsonObject voice = new JsonObject();
|
||||
voice.addProperty("media_id", message.getMedia_id());
|
||||
voice.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add("voice", voice);
|
||||
}
|
||||
|
||||
if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgtype())) {
|
||||
if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) {
|
||||
JsonObject video = new JsonObject();
|
||||
video.addProperty("media_id", message.getMedia_id());
|
||||
video.addProperty("thumb_media_id", message.getThumb_media_id());
|
||||
video.addProperty("media_id", message.getMediaId());
|
||||
video.addProperty("thumb_media_id", message.getThumbMediaId());
|
||||
video.addProperty("title", message.getTitle());
|
||||
video.addProperty("description", message.getDescription());
|
||||
messageJson.add("video", video);
|
||||
}
|
||||
|
||||
if (WxConsts.CUSTOM_MSG_MUSIC.equals(message.getMsgtype())) {
|
||||
if (WxConsts.CUSTOM_MSG_MUSIC.equals(message.getMsgType())) {
|
||||
JsonObject music = new JsonObject();
|
||||
music.addProperty("title", message.getTitle());
|
||||
music.addProperty("description", message.getDescription());
|
||||
music.addProperty("thumb_media_id", message.getThumb_media_id());
|
||||
music.addProperty("musicurl", message.getMusicurl());
|
||||
music.addProperty("hqmusicurl", message.getHqmusicurl());
|
||||
music.addProperty("thumb_media_id", message.getThumbMediaId());
|
||||
music.addProperty("musicurl", message.getMusicUrl());
|
||||
music.addProperty("hqmusicurl", message.getHqMusicUrl());
|
||||
messageJson.add("music", music);
|
||||
}
|
||||
|
||||
if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgtype())) {
|
||||
if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) {
|
||||
JsonArray articleJsonArray = new JsonArray();
|
||||
for (WxCustomMessage.WxArticle article : message.getArticles()) {
|
||||
JsonObject articleJson = new JsonObject();
|
||||
articleJson.addProperty("title", article.getTitle());
|
||||
articleJson.addProperty("description", article.getDescription());
|
||||
articleJson.addProperty("url", article.getUrl());
|
||||
articleJson.addProperty("picurl", article.getPicurl());
|
||||
articleJson.addProperty("picurl", article.getPicUrl());
|
||||
articleJsonArray.add(articleJson);
|
||||
}
|
||||
messageJson.add("articles", articleJsonArray);
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
|
||||
*
|
||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
|
||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
|
||||
* arose from modification of the original source, or other redistribution of this source
|
||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
|
||||
*/
|
||||
package me.chanjar.weixin.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.bean.result.WxError;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxErrorAdapter implements JsonDeserializer<WxError> {
|
||||
|
||||
public WxError deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
WxError wxError = new WxError();
|
||||
JsonObject wxErrorJsonObject = json.getAsJsonObject();
|
||||
|
||||
if (wxErrorJsonObject.get("errcode") != null && !wxErrorJsonObject.get("errcode").isJsonNull()) {
|
||||
wxError.setErrorCode(GsonHelper.getAsPrimitiveInt(wxErrorJsonObject.get("errcode")));
|
||||
}
|
||||
if (wxErrorJsonObject.get("errmsg") != null && !wxErrorJsonObject.get("errmsg").isJsonNull()) {
|
||||
wxError.setErrorMsg(GsonHelper.getAsString(wxErrorJsonObject.get("errmsg")));
|
||||
}
|
||||
return wxError;
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,7 @@
|
||||
package me.chanjar.weixin.util.json;
|
||||
|
||||
import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
import me.chanjar.weixin.bean.WxGroup;
|
||||
import me.chanjar.weixin.bean.WxMassGroupMessage;
|
||||
import me.chanjar.weixin.bean.WxMassNews;
|
||||
import me.chanjar.weixin.bean.WxMassOpenIdsMessage;
|
||||
import me.chanjar.weixin.bean.WxMenu;
|
||||
import me.chanjar.weixin.bean.result.WxUser;
|
||||
import me.chanjar.weixin.bean.result.WxUserList;
|
||||
import me.chanjar.weixin.bean.*;
|
||||
import me.chanjar.weixin.bean.result.*;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@ -26,6 +20,13 @@ public class WxGsonBuilder {
|
||||
INSTANCE.registerTypeAdapter(WxGroup.class, new WxGroupGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxUser.class, new WxUserGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxUserList.class, new WxUserListGsonAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxAccessToken.class, new WxAccessTokenAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxError.class, new WxErrorAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMassVideo.class, new WxMassVideoAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMediaUploadResult.class, new WxMediaUploadResultAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMassSendResult.class, new WxMassSendResultAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxMassUploadResult.class, new WxMassUploadResultAdapter());
|
||||
INSTANCE.registerTypeAdapter(WxQrCodeTicket.class, new WxQrCodeTicketAdapter());
|
||||
}
|
||||
|
||||
public static Gson create() {
|
||||
|
@ -29,12 +29,12 @@ public class WxMassMessageGsonAdapter implements JsonSerializer<WxMassGroupMessa
|
||||
JsonObject messageJson = new JsonObject();
|
||||
|
||||
JsonObject filter = new JsonObject();
|
||||
filter.addProperty("group_id", message.getGroup_id());
|
||||
filter.addProperty("group_id", message.getGroupId());
|
||||
messageJson.add("filter", filter);
|
||||
|
||||
if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgtype())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMedia_id());
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MASS_MSG_NEWS, sub);
|
||||
}
|
||||
if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgtype())) {
|
||||
@ -44,17 +44,17 @@ public class WxMassMessageGsonAdapter implements JsonSerializer<WxMassGroupMessa
|
||||
}
|
||||
if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgtype())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMedia_id());
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MASS_MSG_VOICE, sub);
|
||||
}
|
||||
if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgtype())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMedia_id());
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MASS_MSG_IMAGE, sub);
|
||||
}
|
||||
if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgtype())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMedia_id());
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MASS_MSG_VIDEO, sub);
|
||||
}
|
||||
messageJson.addProperty("msgtype", message.getMsgtype());
|
||||
|
@ -31,20 +31,20 @@ public class WxMassNewsGsonAdapter implements JsonSerializer<WxMassNews> {
|
||||
JsonArray articleJsonArray = new JsonArray();
|
||||
for (WxMassNews.WxMassNewsArticle article : message.getArticles()) {
|
||||
JsonObject articleJson = new JsonObject();
|
||||
articleJson.addProperty("thumb_media_id", article.getThumb_media_id());
|
||||
articleJson.addProperty("thumb_media_id", article.getThumbMediaId());
|
||||
articleJson.addProperty("title", article.getTitle());
|
||||
articleJson.addProperty("content", article.getContent());
|
||||
|
||||
if (null != article.getAuthor()) {
|
||||
articleJson.addProperty("author", article.getAuthor());
|
||||
}
|
||||
if (null != article.getContent_source_url()) {
|
||||
articleJson.addProperty("content_source_url", article.getContent_source_url());
|
||||
if (null != article.getContentSourceUrl()) {
|
||||
articleJson.addProperty("content_source_url", article.getContentSourceUrl());
|
||||
}
|
||||
if (null != article.getDigest()) {
|
||||
articleJson.addProperty("digest", article.getDigest());
|
||||
}
|
||||
articleJson.addProperty("show_cover_pic", article.isShow_cover_pic() ? "1" : "0");
|
||||
articleJson.addProperty("show_cover_pic", article.isShowCoverPic() ? "1" : "0");
|
||||
articleJsonArray.add(articleJson);
|
||||
}
|
||||
newsJson.add("articles", articleJsonArray);
|
||||
|
@ -30,38 +30,38 @@ public class WxMassOpenIdsMessageGsonAdapter implements JsonSerializer<WxMassOpe
|
||||
public JsonElement serialize(WxMassOpenIdsMessage message, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject messageJson = new JsonObject();
|
||||
|
||||
JsonArray touser = new JsonArray();
|
||||
for (String openId : message.getTouser()) {
|
||||
touser.add(new JsonPrimitive(openId));
|
||||
JsonArray toUsers = new JsonArray();
|
||||
for (String openId : message.getToUsers()) {
|
||||
toUsers.add(new JsonPrimitive(openId));
|
||||
}
|
||||
messageJson.add("touser", touser);
|
||||
messageJson.add("touser", toUsers);
|
||||
|
||||
if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgtype())) {
|
||||
if (WxConsts.MASS_MSG_NEWS.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMedia_id());
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MASS_MSG_NEWS, sub);
|
||||
}
|
||||
if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgtype())) {
|
||||
if (WxConsts.MASS_MSG_TEXT.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("content", message.getContent());
|
||||
messageJson.add(WxConsts.MASS_MSG_TEXT, sub);
|
||||
}
|
||||
if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgtype())) {
|
||||
if (WxConsts.MASS_MSG_VOICE.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMedia_id());
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MASS_MSG_VOICE, sub);
|
||||
}
|
||||
if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgtype())) {
|
||||
if (WxConsts.MASS_MSG_IMAGE.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMedia_id());
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MASS_MSG_IMAGE, sub);
|
||||
}
|
||||
if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgtype())) {
|
||||
if (WxConsts.MASS_MSG_VIDEO.equals(message.getMsgType())) {
|
||||
JsonObject sub = new JsonObject();
|
||||
sub.addProperty("media_id", message.getMedia_id());
|
||||
sub.addProperty("media_id", message.getMediaId());
|
||||
messageJson.add(WxConsts.MASS_MSG_VIDEO, sub);
|
||||
}
|
||||
messageJson.addProperty("msgtype", message.getMsgtype());
|
||||
messageJson.addProperty("msgtype", message.getMsgType());
|
||||
return messageJson;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
|
||||
*
|
||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
|
||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
|
||||
* arose from modification of the original source, or other redistribution of this source
|
||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
|
||||
*/
|
||||
package me.chanjar.weixin.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.bean.result.WxMassSendResult;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxMassSendResultAdapter implements JsonDeserializer<WxMassSendResult> {
|
||||
|
||||
public WxMassSendResult deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
WxMassSendResult sendResult = new WxMassSendResult();
|
||||
JsonObject sendResultJsonObject = json.getAsJsonObject();
|
||||
|
||||
if (sendResultJsonObject.get("errcode") != null && !sendResultJsonObject.get("errcode").isJsonNull()) {
|
||||
sendResult.setErrorCode(GsonHelper.getAsString(sendResultJsonObject.get("errcode")));
|
||||
}
|
||||
if (sendResultJsonObject.get("errmsg") != null && !sendResultJsonObject.get("errmsg").isJsonNull()) {
|
||||
sendResult.setErrorMsg(GsonHelper.getAsString(sendResultJsonObject.get("errmsg")));
|
||||
}
|
||||
if (sendResultJsonObject.get("msg_id") != null && !sendResultJsonObject.get("msg_id").isJsonNull()) {
|
||||
sendResult.setMsgId(GsonHelper.getAsString(sendResultJsonObject.get("msg_id")));
|
||||
}
|
||||
return sendResult;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
|
||||
*
|
||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
|
||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
|
||||
* arose from modification of the original source, or other redistribution of this source
|
||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
|
||||
*/
|
||||
package me.chanjar.weixin.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.bean.result.WxMassUploadResult;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxMassUploadResultAdapter implements JsonDeserializer<WxMassUploadResult> {
|
||||
|
||||
public WxMassUploadResult deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
WxMassUploadResult uploadResult = new WxMassUploadResult();
|
||||
JsonObject uploadResultJsonObject = json.getAsJsonObject();
|
||||
|
||||
if (uploadResultJsonObject.get("type") != null && !uploadResultJsonObject.get("type").isJsonNull()) {
|
||||
uploadResult.setType(GsonHelper.getAsString(uploadResultJsonObject.get("type")));
|
||||
}
|
||||
if (uploadResultJsonObject.get("media_id") != null && !uploadResultJsonObject.get("media_id").isJsonNull()) {
|
||||
uploadResult.setMediaId(GsonHelper.getAsString(uploadResultJsonObject.get("media_id")));
|
||||
}
|
||||
if (uploadResultJsonObject.get("created_at") != null && !uploadResultJsonObject.get("created_at").isJsonNull()) {
|
||||
uploadResult.setCreatedAt(GsonHelper.getAsPrimitiveLong(uploadResultJsonObject.get("created_at")));
|
||||
}
|
||||
return uploadResult;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
|
||||
*
|
||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
|
||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
|
||||
* arose from modification of the original source, or other redistribution of this source
|
||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
|
||||
*/
|
||||
package me.chanjar.weixin.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.bean.WxMassVideo;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxMassVideoAdapter implements JsonSerializer<WxMassVideo> {
|
||||
|
||||
public JsonElement serialize(WxMassVideo message, Type typeOfSrc, JsonSerializationContext context) {
|
||||
JsonObject messageJson = new JsonObject();
|
||||
messageJson.addProperty("media_id", message.getMediaId());
|
||||
messageJson.addProperty("description", message.getDescription());
|
||||
messageJson.addProperty("title", message.getTitle());
|
||||
return messageJson;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
|
||||
*
|
||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
|
||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
|
||||
* arose from modification of the original source, or other redistribution of this source
|
||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
|
||||
*/
|
||||
package me.chanjar.weixin.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.bean.result.WxMediaUploadResult;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxMediaUploadResultAdapter implements JsonDeserializer<WxMediaUploadResult> {
|
||||
|
||||
public WxMediaUploadResult deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
WxMediaUploadResult uploadResult = new WxMediaUploadResult();
|
||||
JsonObject uploadResultJsonObject = json.getAsJsonObject();
|
||||
|
||||
if (uploadResultJsonObject.get("type") != null && !uploadResultJsonObject.get("type").isJsonNull()) {
|
||||
uploadResult.setType(GsonHelper.getAsString(uploadResultJsonObject.get("type")));
|
||||
}
|
||||
if (uploadResultJsonObject.get("media_id") != null && !uploadResultJsonObject.get("media_id").isJsonNull()) {
|
||||
uploadResult.setMediaId(GsonHelper.getAsString(uploadResultJsonObject.get("media_id")));
|
||||
}
|
||||
if (uploadResultJsonObject.get("thumb_media_id") != null && !uploadResultJsonObject.get("thumb_media_id").isJsonNull()) {
|
||||
uploadResult.setThumbMediaId(GsonHelper.getAsString(uploadResultJsonObject.get("thumb_media_id")));
|
||||
}
|
||||
if (uploadResultJsonObject.get("created_at") != null && !uploadResultJsonObject.get("created_at").isJsonNull()) {
|
||||
uploadResult.setCreatedAt(GsonHelper.getAsPrimitiveLong(uploadResultJsonObject.get("created_at")));
|
||||
}
|
||||
return uploadResult;
|
||||
}
|
||||
|
||||
}
|
@ -32,7 +32,7 @@ public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializ
|
||||
JsonObject json = new JsonObject();
|
||||
|
||||
JsonArray buttonArray = new JsonArray();
|
||||
for (WxMenu.WxMenuButton button : menu.getButton()) {
|
||||
for (WxMenu.WxMenuButton button : menu.getButtons()) {
|
||||
JsonObject buttonJson = convertToJson(button);
|
||||
buttonArray.add(buttonJson);
|
||||
}
|
||||
@ -47,9 +47,9 @@ public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializ
|
||||
buttonJson.addProperty("name", button.getName());
|
||||
buttonJson.addProperty("key", button.getKey());
|
||||
buttonJson.addProperty("url", button.getUrl());
|
||||
if (button.getSub_button() != null && button.getSub_button().size() > 0) {
|
||||
if (button.getSubButtons() != null && button.getSubButtons().size() > 0) {
|
||||
JsonArray buttonArray = new JsonArray();
|
||||
for (WxMenu.WxMenuButton sub_button : button.getSub_button()) {
|
||||
for (WxMenu.WxMenuButton sub_button : button.getSubButtons()) {
|
||||
buttonArray.add(convertToJson(sub_button));
|
||||
}
|
||||
buttonJson.add("sub_button", buttonArray);
|
||||
@ -69,14 +69,14 @@ public class WxMenuGsonAdapter implements JsonSerializer<WxMenu>, JsonDeserializ
|
||||
for (int i = 0; i < buttonsJson.size(); i++) {
|
||||
JsonObject buttonJson = buttonsJson.get(i).getAsJsonObject();
|
||||
WxMenu.WxMenuButton button = convertFromJson(buttonJson);
|
||||
menu.getButton().add(button);
|
||||
menu.getButtons().add(button);
|
||||
if (buttonJson.get("sub_button") == null || buttonJson.get("sub_button").isJsonNull()) {
|
||||
continue;
|
||||
}
|
||||
JsonArray sub_buttonsJson = buttonJson.get("sub_button").getAsJsonArray();
|
||||
for (int j = 0; j < sub_buttonsJson.size(); j++) {
|
||||
JsonObject sub_buttonJson = sub_buttonsJson.get(j).getAsJsonObject();
|
||||
button.getSub_button().add(convertFromJson(sub_buttonJson));
|
||||
button.getSubButtons().add(convertFromJson(sub_buttonJson));
|
||||
}
|
||||
}
|
||||
return menu;
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* KINGSTAR MEDIA SOLUTIONS Co.,LTD. Copyright c 2005-2013. All rights reserved.
|
||||
*
|
||||
* This source code is the property of KINGSTAR MEDIA SOLUTIONS LTD. It is intended
|
||||
* only for the use of KINGSTAR MEDIA application development. Reengineering, reproduction
|
||||
* arose from modification of the original source, or other redistribution of this source
|
||||
* is not permitted without written permission of the KINGSTAR MEDIA SOLUTIONS LTD.
|
||||
*/
|
||||
package me.chanjar.weixin.util.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.chanjar.weixin.bean.result.WxMassUploadResult;
|
||||
import me.chanjar.weixin.bean.result.WxQrCodeTicket;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
public class WxQrCodeTicketAdapter implements JsonDeserializer<WxQrCodeTicket> {
|
||||
|
||||
public WxQrCodeTicket deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
WxQrCodeTicket ticket = new WxQrCodeTicket();
|
||||
JsonObject ticketJsonObject = json.getAsJsonObject();
|
||||
|
||||
if (ticketJsonObject.get("ticket") != null && !ticketJsonObject.get("ticket").isJsonNull()) {
|
||||
ticket.setTicket(GsonHelper.getAsString(ticketJsonObject.get("ticket")));
|
||||
}
|
||||
if (ticketJsonObject.get("expire_seconds") != null && !ticketJsonObject.get("expire_seconds").isJsonNull()) {
|
||||
ticket.setExpire_seconds(GsonHelper.getAsPrimitiveInt(ticketJsonObject.get("expire_seconds")));
|
||||
}
|
||||
if (ticketJsonObject.get("url") != null && !ticketJsonObject.get("url").isJsonNull()) {
|
||||
ticket.setUrl(GsonHelper.getAsString(ticketJsonObject.get("url")));
|
||||
}
|
||||
return ticket;
|
||||
}
|
||||
|
||||
}
|
@ -31,13 +31,13 @@ public class WxUserGsonAdapter implements JsonDeserializer<WxUser> {
|
||||
wxUser.setSubscribe(new Integer(0).equals(GsonHelper.getInteger(o, "subscribe")) ? false : true);
|
||||
wxUser.setCity(GsonHelper.getString(o, "city"));
|
||||
wxUser.setCountry(GsonHelper.getString(o, "country"));
|
||||
wxUser.setHeadimgurl(GsonHelper.getString(o, "headimgurl"));
|
||||
wxUser.setHeadImgUrl(GsonHelper.getString(o, "headimgurl"));
|
||||
wxUser.setLanguage(GsonHelper.getString(o, "language"));
|
||||
wxUser.setNickname(GsonHelper.getString(o, "nickname"));
|
||||
wxUser.setOpenid(GsonHelper.getString(o, "openid"));
|
||||
wxUser.setOpenId(GsonHelper.getString(o, "openid"));
|
||||
wxUser.setProvince(GsonHelper.getString(o, "province"));
|
||||
wxUser.setSubscribe_time(GsonHelper.getLong(o, "subscribe_time"));
|
||||
wxUser.setUnionid(GsonHelper.getString(o, "unionid"));
|
||||
wxUser.setSubscribeTime(GsonHelper.getLong(o, "subscribe_time"));
|
||||
wxUser.setUnionId(GsonHelper.getString(o, "unionid"));
|
||||
Integer sex = GsonHelper.getInteger(o, "sex");
|
||||
if(new Integer(1).equals(sex)) {
|
||||
wxUser.setSex("男");
|
||||
|
@ -31,10 +31,10 @@ public class WxUserListGsonAdapter implements JsonDeserializer<WxUserList> {
|
||||
WxUserList wxUserList = new WxUserList();
|
||||
wxUserList.setTotal(GsonHelper.getInteger(o, "total"));
|
||||
wxUserList.setCount(GsonHelper.getInteger(o, "count"));
|
||||
wxUserList.setNext_openid(GsonHelper.getString(o, "next_openid"));
|
||||
wxUserList.setNextOpenId(GsonHelper.getString(o, "next_openid"));
|
||||
JsonArray data = o.get("data").getAsJsonObject().get("openid").getAsJsonArray();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
wxUserList.getOpenids().add(GsonHelper.getAsString(data.get(i)));
|
||||
wxUserList.getOpenIds().add(GsonHelper.getAsString(data.get(i)));
|
||||
}
|
||||
return wxUserList;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ public class WxCustomMessageAPITest {
|
||||
public void testSendCustomMessage() throws WxErrorException {
|
||||
ApiTestModule.WxXmlConfigStorage configStorage = (ApiTestModule.WxXmlConfigStorage) wxService.wxConfigStorage;
|
||||
WxCustomMessage message = new WxCustomMessage();
|
||||
message.setMsgtype(WxConsts.CUSTOM_MSG_TEXT);
|
||||
message.setTouser(configStorage.getOpenId());
|
||||
message.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
|
||||
message.setToUser(configStorage.getOpenId());
|
||||
message.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
|
||||
wxService.customMessageSend(message);
|
||||
|
@ -38,13 +38,13 @@ public class WxMassMessageAPITest {
|
||||
// 发送群发消息
|
||||
WxXmlConfigStorage configProvider = (WxXmlConfigStorage) wxService.wxConfigStorage;
|
||||
WxMassOpenIdsMessage massMessage = new WxMassOpenIdsMessage();
|
||||
massMessage.setMsgtype(WxConsts.MASS_MSG_TEXT);
|
||||
massMessage.setMsgType(WxConsts.MASS_MSG_TEXT);
|
||||
massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
massMessage.getTouser().add(configProvider.getOpenId());
|
||||
massMessage.getToUsers().add(configProvider.getOpenId());
|
||||
|
||||
WxMassSendResult massResult = wxService.massOpenIdsMessageSend(massMessage);
|
||||
Assert.assertNotNull(massResult);
|
||||
Assert.assertNotNull(massResult.getMsg_id());
|
||||
Assert.assertNotNull(massResult.getMsgId());
|
||||
}
|
||||
|
||||
@Test(dataProvider="massMessages")
|
||||
@ -52,13 +52,13 @@ public class WxMassMessageAPITest {
|
||||
// 发送群发消息
|
||||
WxXmlConfigStorage configProvider = (WxXmlConfigStorage) wxService.wxConfigStorage;
|
||||
WxMassOpenIdsMessage massMessage = new WxMassOpenIdsMessage();
|
||||
massMessage.setMsgtype(massMsgType);
|
||||
massMessage.setMedia_id(mediaId);
|
||||
massMessage.getTouser().add(configProvider.getOpenId());
|
||||
massMessage.setMsgType(massMsgType);
|
||||
massMessage.setMediaId(mediaId);
|
||||
massMessage.getToUsers().add(configProvider.getOpenId());
|
||||
|
||||
WxMassSendResult massResult = wxService.massOpenIdsMessageSend(massMessage);
|
||||
Assert.assertNotNull(massResult);
|
||||
Assert.assertNotNull(massResult.getMsg_id());
|
||||
Assert.assertNotNull(massResult.getMsgId());
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -66,23 +66,23 @@ public class WxMassMessageAPITest {
|
||||
WxMassGroupMessage massMessage = new WxMassGroupMessage();
|
||||
massMessage.setMsgtype(WxConsts.MASS_MSG_TEXT);
|
||||
massMessage.setContent("测试群发消息\n欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
|
||||
massMessage.setGroup_id(wxService.groupGet().get(0).getId());
|
||||
massMessage.setGroupId(wxService.groupGet().get(0).getId());
|
||||
|
||||
WxMassSendResult massResult = wxService.massGroupMessageSend(massMessage);
|
||||
Assert.assertNotNull(massResult);
|
||||
Assert.assertNotNull(massResult.getMsg_id());
|
||||
Assert.assertNotNull(massResult.getMsgId());
|
||||
}
|
||||
|
||||
@Test(dataProvider="massMessages")
|
||||
public void testMediaMassGroupMessageSend(String massMsgType, String mediaId) throws WxErrorException, IOException {
|
||||
WxMassGroupMessage massMessage = new WxMassGroupMessage();
|
||||
massMessage.setMsgtype(massMsgType);
|
||||
massMessage.setMedia_id(mediaId);
|
||||
massMessage.setGroup_id(wxService.groupGet().get(0).getId());
|
||||
massMessage.setMediaId(mediaId);
|
||||
massMessage.setGroupId(wxService.groupGet().get(0).getId());
|
||||
|
||||
WxMassSendResult massResult = wxService.massGroupMessageSend(massMessage);
|
||||
Assert.assertNotNull(massResult);
|
||||
Assert.assertNotNull(massResult.getMsg_id());
|
||||
Assert.assertNotNull(massResult.getMsgId());
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
@ -96,17 +96,17 @@ public class WxMassMessageAPITest {
|
||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.mp4");
|
||||
WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMedia_id());
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
|
||||
// 把视频变成可被群发的媒体
|
||||
WxMassVideo video = new WxMassVideo();
|
||||
video.setTitle("测试标题");
|
||||
video.setDescription("测试描述");
|
||||
video.setMedia_id(uploadMediaRes.getMedia_id());
|
||||
video.setMediaId(uploadMediaRes.getMediaId());
|
||||
WxMassUploadResult uploadResult = wxService.massVideoUpload(video);
|
||||
Assert.assertNotNull(uploadResult);
|
||||
Assert.assertNotNull(uploadResult.getMedia_id());
|
||||
messages[0] = new Object[] { WxConsts.MASS_MSG_VIDEO, uploadResult.getMedia_id() };
|
||||
Assert.assertNotNull(uploadResult.getMediaId());
|
||||
messages[0] = new Object[] { WxConsts.MASS_MSG_VIDEO, uploadResult.getMediaId() };
|
||||
}
|
||||
/**
|
||||
* 图片素材
|
||||
@ -115,8 +115,8 @@ public class WxMassMessageAPITest {
|
||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg");
|
||||
WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMedia_id());
|
||||
messages[1] = new Object[] { WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMedia_id() };
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
messages[1] = new Object[] { WxConsts.MASS_MSG_IMAGE, uploadMediaRes.getMediaId() };
|
||||
}
|
||||
/**
|
||||
* 语音素材
|
||||
@ -125,8 +125,8 @@ public class WxMassMessageAPITest {
|
||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.mp3");
|
||||
WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMedia_id());
|
||||
messages[2] = new Object[] { WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMedia_id() };
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
messages[2] = new Object[] { WxConsts.MASS_MSG_VOICE, uploadMediaRes.getMediaId() };
|
||||
}
|
||||
/**
|
||||
* 图文素材
|
||||
@ -136,30 +136,30 @@ public class WxMassMessageAPITest {
|
||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream("mm.jpeg");
|
||||
WxMediaUploadResult uploadMediaRes = wxService.mediaUpload(WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, inputStream);
|
||||
Assert.assertNotNull(uploadMediaRes);
|
||||
Assert.assertNotNull(uploadMediaRes.getMedia_id());
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
|
||||
// 上传图文消息
|
||||
WxMassNews news = new WxMassNews();
|
||||
WxMassNewsArticle article1 = new WxMassNewsArticle();
|
||||
article1.setTitle("标题1");
|
||||
article1.setContent("内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1内容1");
|
||||
article1.setThumb_media_id(uploadMediaRes.getMedia_id());
|
||||
article1.setThumbMediaId(uploadMediaRes.getMediaId());
|
||||
news.addArticle(article1);
|
||||
|
||||
WxMassNewsArticle article2 = new WxMassNewsArticle();
|
||||
article2.setTitle("标题2");
|
||||
article2.setContent("内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2内容2");
|
||||
article2.setThumb_media_id(uploadMediaRes.getMedia_id());
|
||||
article2.setShow_cover_pic(true);
|
||||
article2.setThumbMediaId(uploadMediaRes.getMediaId());
|
||||
article2.setShowCoverPic(true);
|
||||
article2.setAuthor("作者2");
|
||||
article2.setContent_source_url("www.baidu.com");
|
||||
article2.setContentSourceUrl("www.baidu.com");
|
||||
article2.setDigest("摘要2");
|
||||
news.addArticle(article2);
|
||||
|
||||
WxMassUploadResult massUploadResult = wxService.massNewsUpload(news);
|
||||
Assert.assertNotNull(massUploadResult);
|
||||
Assert.assertNotNull(uploadMediaRes.getMedia_id());
|
||||
messages[3] = new Object[] { WxConsts.MASS_MSG_NEWS, massUploadResult.getMedia_id() };
|
||||
Assert.assertNotNull(uploadMediaRes.getMediaId());
|
||||
messages[3] = new Object[] { WxConsts.MASS_MSG_NEWS, massUploadResult.getMediaId() };
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
@ -34,14 +34,14 @@ public class WxMediaAPITest {
|
||||
InputStream inputStream = ClassLoader.getSystemResourceAsStream(fileName);
|
||||
WxMediaUploadResult res = wxService.mediaUpload(mediaType, fileType, inputStream);
|
||||
Assert.assertNotNull(res.getType());
|
||||
Assert.assertNotNull(res.getCreated_at());
|
||||
Assert.assertTrue(res.getMedia_id() != null || res.getThumb_media_id() != null);
|
||||
Assert.assertNotNull(res.getCreatedAt());
|
||||
Assert.assertTrue(res.getMediaId() != null || res.getThumbMediaId() != null);
|
||||
|
||||
if (res.getMedia_id() != null) {
|
||||
media_ids.add(res.getMedia_id());
|
||||
if (res.getMediaId() != null) {
|
||||
media_ids.add(res.getMediaId());
|
||||
}
|
||||
if (res.getThumb_media_id() != null) {
|
||||
media_ids.add(res.getThumb_media_id());
|
||||
if (res.getThumbMediaId() != null) {
|
||||
media_ids.add(res.getThumbMediaId());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,9 +56,9 @@ public class WxMenuAPITest {
|
||||
WxMenuButton button3 = new WxMenuButton();
|
||||
button3.setName("菜单");
|
||||
|
||||
menu.getButton().add(button1);
|
||||
menu.getButton().add(button2);
|
||||
menu.getButton().add(button3);
|
||||
menu.getButtons().add(button1);
|
||||
menu.getButtons().add(button2);
|
||||
menu.getButtons().add(button3);
|
||||
|
||||
WxMenuButton button31 = new WxMenuButton();
|
||||
button31.setType(WxConsts.BUTTON_VIEW);
|
||||
@ -75,9 +75,9 @@ public class WxMenuAPITest {
|
||||
button33.setName("赞一下我们");
|
||||
button33.setKey("V1001_GOOD");
|
||||
|
||||
button3.getSub_button().add(button31);
|
||||
button3.getSub_button().add(button32);
|
||||
button3.getSub_button().add(button33);
|
||||
button3.getSubButtons().add(button31);
|
||||
button3.getSubButtons().add(button32);
|
||||
button3.getSubButtons().add(button33);
|
||||
|
||||
return new Object[][] {
|
||||
new Object[] {
|
||||
|
@ -71,7 +71,6 @@ public class WxMessageRouterTest {
|
||||
router.rule().handler(new WxMessageHandler() {
|
||||
@Override
|
||||
public WxXmlOutMessage handle(WxXmlMessage wxMessage, Map<String, Object> context) {
|
||||
System.out.println(wxMessage.toString());
|
||||
return null;
|
||||
}
|
||||
}).end();
|
||||
|
@ -39,7 +39,7 @@ public class WxUserAPITest {
|
||||
Assert.assertNotNull(wxUserList);
|
||||
Assert.assertFalse(wxUserList.getCount() == -1);
|
||||
Assert.assertFalse(wxUserList.getTotal() == -1);
|
||||
Assert.assertFalse(wxUserList.getOpenids().size() == -1);
|
||||
Assert.assertFalse(wxUserList.getOpenIds().size() == -1);
|
||||
}
|
||||
|
||||
public void testGroupQueryUserGroup() throws WxErrorException {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.chanjar.weixin.bean;
|
||||
|
||||
import me.chanjar.weixin.bean.WxAccessToken;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -11,8 +10,8 @@ public class WxAccessTokenTest {
|
||||
|
||||
String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}";
|
||||
WxAccessToken wxError = WxAccessToken.fromJson(json);
|
||||
Assert.assertEquals(wxError.getAccess_token(), "ACCESS_TOKEN");
|
||||
Assert.assertTrue(wxError.getExpires_in() == 7200);
|
||||
Assert.assertEquals(wxError.getAccessToken(), "ACCESS_TOKEN");
|
||||
Assert.assertTrue(wxError.getExpiresIn() == 7200);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.chanjar.weixin.bean;
|
||||
|
||||
import me.chanjar.weixin.bean.WxCustomMessage;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -12,8 +11,8 @@ public class WxCustomMessageTest {
|
||||
|
||||
public void testTextReply() {
|
||||
WxCustomMessage reply = new WxCustomMessage();
|
||||
reply.setTouser("OPENID");
|
||||
reply.setMsgtype(WxConsts.CUSTOM_MSG_TEXT);
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
|
||||
reply.setContent("sfsfdsdf");
|
||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"text\",\"text\":{\"content\":\"sfsfdsdf\"}}");
|
||||
}
|
||||
@ -25,9 +24,9 @@ public class WxCustomMessageTest {
|
||||
|
||||
public void testImageReply() {
|
||||
WxCustomMessage reply = new WxCustomMessage();
|
||||
reply.setTouser("OPENID");
|
||||
reply.setMsgtype(WxConsts.CUSTOM_MSG_IMAGE);
|
||||
reply.setMedia_id("MEDIA_ID");
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.CUSTOM_MSG_IMAGE);
|
||||
reply.setMediaId("MEDIA_ID");
|
||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"image\",\"image\":{\"media_id\":\"MEDIA_ID\"}}");
|
||||
}
|
||||
|
||||
@ -38,9 +37,9 @@ public class WxCustomMessageTest {
|
||||
|
||||
public void testVoiceReply() {
|
||||
WxCustomMessage reply = new WxCustomMessage();
|
||||
reply.setTouser("OPENID");
|
||||
reply.setMsgtype(WxConsts.CUSTOM_MSG_VOICE);
|
||||
reply.setMedia_id("MEDIA_ID");
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.CUSTOM_MSG_VOICE);
|
||||
reply.setMediaId("MEDIA_ID");
|
||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"voice\",\"voice\":{\"media_id\":\"MEDIA_ID\"}}");
|
||||
}
|
||||
|
||||
@ -51,10 +50,10 @@ public class WxCustomMessageTest {
|
||||
|
||||
public void testVideoReply() {
|
||||
WxCustomMessage reply = new WxCustomMessage();
|
||||
reply.setTouser("OPENID");
|
||||
reply.setMsgtype(WxConsts.CUSTOM_MSG_VIDEO);
|
||||
reply.setMedia_id("MEDIA_ID");
|
||||
reply.setThumb_media_id("MEDIA_ID");
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.CUSTOM_MSG_VIDEO);
|
||||
reply.setMediaId("MEDIA_ID");
|
||||
reply.setThumbMediaId("MEDIA_ID");
|
||||
reply.setTitle("TITLE");
|
||||
reply.setDescription("DESCRIPTION");
|
||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"video\",\"video\":{\"media_id\":\"MEDIA_ID\",\"thumb_media_id\":\"MEDIA_ID\",\"title\":\"TITLE\",\"description\":\"DESCRIPTION\"}}");
|
||||
@ -67,13 +66,13 @@ public class WxCustomMessageTest {
|
||||
|
||||
public void testMusicReply() {
|
||||
WxCustomMessage reply = new WxCustomMessage();
|
||||
reply.setTouser("OPENID");
|
||||
reply.setMsgtype(WxConsts.CUSTOM_MSG_MUSIC);
|
||||
reply.setThumb_media_id("MEDIA_ID");
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.CUSTOM_MSG_MUSIC);
|
||||
reply.setThumbMediaId("MEDIA_ID");
|
||||
reply.setDescription("DESCRIPTION");
|
||||
reply.setTitle("TITLE");
|
||||
reply.setMusicurl("MUSIC_URL");
|
||||
reply.setHqmusicurl("HQ_MUSIC_URL");
|
||||
reply.setMusicUrl("MUSIC_URL");
|
||||
reply.setHqMusicUrl("HQ_MUSIC_URL");
|
||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"music\",\"music\":{\"title\":\"TITLE\",\"description\":\"DESCRIPTION\",\"thumb_media_id\":\"MEDIA_ID\",\"musicurl\":\"MUSIC_URL\",\"hqmusicurl\":\"HQ_MUSIC_URL\"}}");
|
||||
}
|
||||
|
||||
@ -84,26 +83,26 @@ public class WxCustomMessageTest {
|
||||
.thumbMediaId("MEDIA_ID")
|
||||
.description("DESCRIPTION")
|
||||
.musicUrl("MUSIC_URL")
|
||||
.hqmusicUrl("HQ_MUSIC_URL")
|
||||
.hqMusicUrl("HQ_MUSIC_URL")
|
||||
.build();
|
||||
Assert.assertEquals(reply.toJson(), "{\"touser\":\"OPENID\",\"msgtype\":\"music\",\"music\":{\"title\":\"TITLE\",\"description\":\"DESCRIPTION\",\"thumb_media_id\":\"MEDIA_ID\",\"musicurl\":\"MUSIC_URL\",\"hqmusicurl\":\"HQ_MUSIC_URL\"}}");
|
||||
}
|
||||
|
||||
public void testNewsReply() {
|
||||
WxCustomMessage reply = new WxCustomMessage();
|
||||
reply.setTouser("OPENID");
|
||||
reply.setMsgtype(WxConsts.CUSTOM_MSG_NEWS);
|
||||
reply.setToUser("OPENID");
|
||||
reply.setMsgType(WxConsts.CUSTOM_MSG_NEWS);
|
||||
|
||||
WxArticle article1 = new WxArticle();
|
||||
article1.setUrl("URL");
|
||||
article1.setPicurl("PIC_URL");
|
||||
article1.setPicUrl("PIC_URL");
|
||||
article1.setDescription("Is Really A Happy Day");
|
||||
article1.setTitle("Happy Day");
|
||||
reply.getArticles().add(article1);
|
||||
|
||||
WxArticle article2 = new WxArticle();
|
||||
article2.setUrl("URL");
|
||||
article2.setPicurl("PIC_URL");
|
||||
article2.setPicUrl("PIC_URL");
|
||||
article2.setDescription("Is Really A Happy Day");
|
||||
article2.setTitle("Happy Day");
|
||||
reply.getArticles().add(article2);
|
||||
@ -115,13 +114,13 @@ public class WxCustomMessageTest {
|
||||
public void testNewsBuild() {
|
||||
WxArticle article1 = new WxArticle();
|
||||
article1.setUrl("URL");
|
||||
article1.setPicurl("PIC_URL");
|
||||
article1.setPicUrl("PIC_URL");
|
||||
article1.setDescription("Is Really A Happy Day");
|
||||
article1.setTitle("Happy Day");
|
||||
|
||||
WxArticle article2 = new WxArticle();
|
||||
article2.setUrl("URL");
|
||||
article2.setPicurl("PIC_URL");
|
||||
article2.setPicUrl("PIC_URL");
|
||||
article2.setDescription("Is Really A Happy Day");
|
||||
article2.setTitle("Happy Day");
|
||||
|
||||
|
@ -12,8 +12,8 @@ public class WxErrorTest {
|
||||
|
||||
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\" }";
|
||||
WxError wxError = WxError.fromJson(json);
|
||||
Assert.assertTrue(wxError.getErrcode() == 40003);
|
||||
Assert.assertEquals(wxError.getErrmsg(), "invalid openid");
|
||||
Assert.assertTrue(wxError.getErrorCode() == 40003);
|
||||
Assert.assertEquals(wxError.getErrorMsg(), "invalid openid");
|
||||
|
||||
}
|
||||
|
||||
@ -21,8 +21,8 @@ public class WxErrorTest {
|
||||
|
||||
String json = "{ \"errcode\": 40003, \"errmsg\": \"invalid openid\", \"media_id\": \"12323423dsfafsf232f\" }";
|
||||
WxError wxError = WxError.fromJson(json);
|
||||
Assert.assertTrue(wxError.getErrcode() == 40003);
|
||||
Assert.assertEquals(wxError.getErrmsg(), "invalid openid");
|
||||
Assert.assertTrue(wxError.getErrorCode() == 40003);
|
||||
Assert.assertEquals(wxError.getErrorMsg(), "invalid openid");
|
||||
|
||||
}
|
||||
|
||||
@ -30,8 +30,8 @@ public class WxErrorTest {
|
||||
|
||||
String json = "{\"access_token\":\"ACCESS_TOKEN\",\"expires_in\":7200}";
|
||||
WxError wxError = WxError.fromJson(json);
|
||||
Assert.assertTrue(wxError.getErrcode() == 0);
|
||||
Assert.assertEquals(wxError.getErrmsg(), null);
|
||||
Assert.assertTrue(wxError.getErrorCode() == 0);
|
||||
Assert.assertEquals(wxError.getErrorMsg(), null);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.chanjar.weixin.bean;
|
||||
|
||||
import me.chanjar.weixin.bean.WxMenu;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
@ -13,7 +12,7 @@ public class WxMenuTest {
|
||||
@Test(dataProvider="wxReturnMenu")
|
||||
public void testFromJson(String json) {
|
||||
WxMenu menu = WxMenu.fromJson(json);
|
||||
Assert.assertEquals(menu.getButton().size(), 3);
|
||||
Assert.assertEquals(menu.getButtons().size(), 3);
|
||||
}
|
||||
|
||||
@Test(dataProvider="wxPushMenu")
|
||||
@ -32,9 +31,9 @@ public class WxMenuTest {
|
||||
WxMenuButton button3 = new WxMenuButton();
|
||||
button3.setName("菜单");
|
||||
|
||||
menu.getButton().add(button1);
|
||||
menu.getButton().add(button2);
|
||||
menu.getButton().add(button3);
|
||||
menu.getButtons().add(button1);
|
||||
menu.getButtons().add(button2);
|
||||
menu.getButtons().add(button3);
|
||||
|
||||
WxMenuButton button31 = new WxMenuButton();
|
||||
button31.setType("view");
|
||||
@ -51,9 +50,9 @@ public class WxMenuTest {
|
||||
button33.setName("赞一下我们");
|
||||
button33.setKey("V1001_GOOD");
|
||||
|
||||
button3.getSub_button().add(button31);
|
||||
button3.getSub_button().add(button32);
|
||||
button3.getSub_button().add(button33);
|
||||
button3.getSubButtons().add(button31);
|
||||
button3.getSubButtons().add(button32);
|
||||
button3.getSubButtons().add(button33);
|
||||
|
||||
Assert.assertEquals(menu.toJson(), json);
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ public class WxXmlMessageTest {
|
||||
Assert.assertEquals(wxMessage.getMediaId(), "media_id");
|
||||
Assert.assertEquals(wxMessage.getFormat(), "Format");
|
||||
Assert.assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id");
|
||||
Assert.assertEquals(wxMessage.getLocation_X(), new Double(23.134521d));
|
||||
Assert.assertEquals(wxMessage.getLocation_Y(), new Double(113.358803d));
|
||||
Assert.assertEquals(wxMessage.getLocationX(), new Double(23.134521d));
|
||||
Assert.assertEquals(wxMessage.getLocationY(), new Double(113.358803d));
|
||||
Assert.assertEquals(wxMessage.getScale(), new Double(20));
|
||||
Assert.assertEquals(wxMessage.getLabel(), "位置信息");
|
||||
Assert.assertEquals(wxMessage.getDescription(), "公众平台官网链接");
|
||||
@ -81,8 +81,8 @@ public class WxXmlMessageTest {
|
||||
Assert.assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1");
|
||||
Assert.assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1l));
|
||||
Assert.assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185");
|
||||
Assert.assertEquals(wxMessage.getSendLocationInfo().getLocation_X(), "23");
|
||||
Assert.assertEquals(wxMessage.getSendLocationInfo().getLocation_Y(), "113");
|
||||
Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23");
|
||||
Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113");
|
||||
Assert.assertEquals(wxMessage.getSendLocationInfo().getScale(), "15");
|
||||
Assert.assertEquals(wxMessage.getSendLocationInfo().getLabel(), " 广州市海珠区客村艺苑路 106号");
|
||||
Assert.assertEquals(wxMessage.getSendLocationInfo().getPoiname(), "wo de poi");
|
||||
|
@ -1,7 +1,5 @@
|
||||
package me.chanjar.weixin.bean;
|
||||
|
||||
import me.chanjar.weixin.bean.WxXmlOutMessage;
|
||||
import me.chanjar.weixin.bean.WxXmlOutMusicMessage;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -12,7 +10,7 @@ public class WxXmlOutIMusicMessageTest {
|
||||
WxXmlOutMusicMessage m = new WxXmlOutMusicMessage();
|
||||
m.setTitle("title");
|
||||
m.setDescription("ddfff");
|
||||
m.setHQMusicUrl("hQMusicUrl");
|
||||
m.setHqMusicUrl("hQMusicUrl");
|
||||
m.setMusicUrl("musicUrl");
|
||||
m.setThumbMediaId("thumbMediaId");
|
||||
m.setCreateTime(1122l);
|
||||
@ -43,7 +41,7 @@ public class WxXmlOutIMusicMessageTest {
|
||||
.touser("toUser")
|
||||
.title("title")
|
||||
.description("ddfff")
|
||||
.hqmusicUrl("hQMusicUrl")
|
||||
.hqMusicUrl("hQMusicUrl")
|
||||
.musicUrl("musicUrl")
|
||||
.thumbMediaId("thumbMediaId")
|
||||
.build();
|
||||
|
Loading…
Reference in New Issue
Block a user