diff --git a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/WeixinProxy.java b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/WeixinProxy.java
index 1ba7d53f..091b7b57 100644
--- a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/WeixinProxy.java
+++ b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/WeixinProxy.java
@@ -129,8 +129,8 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.util.Weixin4jSettings
*/
public WeixinProxy(Weixin4jSettings settings) {
- this(new TokenHolder(new WeixinTokenCreator(settings.getWeixinAccount()
- .getId(), settings.getWeixinAccount().getSecret()),
+ this(new TokenHolder(
+ new WeixinTokenCreator(settings.getWeixinAccount().getId(), settings.getWeixinAccount().getSecret()),
settings.getTokenStorager0()));
this.settings = settings;
}
@@ -182,8 +182,7 @@ public class WeixinProxy {
* @return
*/
public TokenHolder getTicketHolder(TicketType ticketType) {
- return new TokenHolder(new WeixinTicketCreator(getWeixinAccount()
- .getId(), ticketType, this.tokenHolder),
+ return new TokenHolder(new WeixinTicketCreator(getWeixinAccount().getId(), ticketType, this.tokenHolder),
this.settings.getTokenStorager0());
}
@@ -199,8 +198,7 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @throws WeixinException
*/
- public String uploadImage(InputStream is, String fileName)
- throws WeixinException {
+ public String uploadImage(InputStream is, String fileName) throws WeixinException {
return mediaApi.uploadImage(is, fileName);
}
@@ -218,17 +216,19 @@ public class WeixinProxy {
* @return 群发视频消息对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MediaApi
- * @see 高级群发
+ * @see
+ * 高级群发
* @see com.foxinmy.weixin4j.tuple.MpVideo
*/
- public MpVideo uploadVideo(InputStream is, String fileName, String title,
- String description) throws WeixinException {
+ public MpVideo uploadVideo(InputStream is, String fileName, String title, String description)
+ throws WeixinException {
return mediaApi.uploadVideo(is, fileName, title, description);
}
/**
- * 上传媒体文件 此接口只包含图片、语音、缩略图、视频(临时)四种媒体类型的上传
+ * 上传媒体文件
+ * 此接口只包含图片、语音、缩略图、视频(临时)四种媒体类型的上传
*
* 正常情况下返回{"type":"TYPE","media_id":"MEDIA_ID","created_at":123456789},
* 否则抛出异常.
@@ -241,17 +241,18 @@ public class WeixinProxy {
* @param fileName
* 文件名
* @return 上传到微信服务器返回的媒体标识
- * @see 上传临时素材
- * @see 上传永久素材
+ * @see
+ * 上传临时素材
+ * @see
+ * 上传永久素材
* @see com.foxinmy.weixin4j.model.MediaUploadResult
* @see com.foxinmy.weixin4j.type.MediaType
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @throws WeixinException
*/
- public MediaUploadResult uploadMedia(boolean isMaterial, InputStream is,
- String fileName) throws WeixinException {
+ public MediaUploadResult uploadMedia(boolean isMaterial, InputStream is, String fileName) throws WeixinException {
return mediaApi.uploadMedia(isMaterial, is, fileName);
}
@@ -266,11 +267,11 @@ public class WeixinProxy {
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @see com.foxinmy.weixin4j.model.MediaDownloadResult
- * @see 上传下载说明
+ * @see
+ * 上传下载说明
*/
- public MediaDownloadResult downloadMedia(String mediaId, boolean isMaterial)
- throws WeixinException {
+ public MediaDownloadResult downloadMedia(String mediaId, boolean isMaterial) throws WeixinException {
return mediaApi.downloadMedia(mediaId, isMaterial);
}
@@ -287,11 +288,11 @@ public class WeixinProxy {
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @see com.foxinmy.weixin4j.tuple.MpArticle
- * @see 上传永久媒体素材
+ * @see
+ * 上传永久媒体素材
*/
- public String uploadMaterialArticle(List articles)
- throws WeixinException {
+ public String uploadMaterialArticle(List articles) throws WeixinException {
return mediaApi.uploadMaterialArticle(articles);
}
@@ -306,8 +307,7 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.tuple.MpArticle
* @see com.foxinmy.weixin4j.mp.api.MediaApi
*/
- public List downloadArticle(String mediaId)
- throws WeixinException {
+ public List downloadArticle(String mediaId) throws WeixinException {
return mediaApi.downloadArticle(mediaId);
}
@@ -324,11 +324,12 @@ public class WeixinProxy {
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @see com.foxinmy.weixin4j.tuple.MpArticle
- * @see 更新永久图文素材
+ * @see
+ * 更新永久图文素材
*/
- public JsonResult updateMaterialArticle(String mediaId, int index,
- List articles) throws WeixinException {
+ public JsonResult updateMaterialArticle(String mediaId, int index, List articles)
+ throws WeixinException {
return mediaApi.updateMaterialArticle(mediaId, index, articles);
}
@@ -340,11 +341,11 @@ public class WeixinProxy {
* @return 处理结果
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MediaApi
- * @see 删除永久媒体素材
+ * @see
+ * 删除永久媒体素材
*/
- public JsonResult deleteMaterialMedia(String mediaId)
- throws WeixinException {
+ public JsonResult deleteMaterialMedia(String mediaId) throws WeixinException {
return mediaApi.deleteMaterialMedia(mediaId);
}
@@ -360,24 +361,27 @@ public class WeixinProxy {
* @param introduction
* 视频描述
* @return 上传到微信服务器返回的媒体标识
- * @see 上传永久媒体素材
+ * @see
+ * 上传永久媒体素材
* @see com.foxinmy.weixin4j.mp.api.MediaApi
* @throws WeixinException
*/
- public String uploadMaterialVideo(InputStream is, String fileName,
- String title, String introduction) throws WeixinException {
+ public String uploadMaterialVideo(InputStream is, String fileName, String title, String introduction)
+ throws WeixinException {
return mediaApi.uploadMaterialVideo(is, fileName, title, introduction);
}
/**
- * 获取永久媒体素材的总数 .图片和图文消息素材(包括单图文和多图文)的总数上限为5000,其他素材的总数上限为1000
+ * 获取永久媒体素材的总数
+ * .图片和图文消息素材(包括单图文和多图文)的总数上限为5000,其他素材的总数上限为1000
*
* @return 总数对象
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.model.MediaCounter
- * @see 获取素材总数
+ * @see
+ * 获取素材总数
* @see com.foxinmy.weixin4j.mp.api.MediaApi
*/
public MediaCounter countMaterialMedia() throws WeixinException {
@@ -399,11 +403,11 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.model.MediaItem
* @see com.foxinmy.weixin4j.model.Pageable
* @see com.foxinmy.weixin4j.model.Pagedata
- * @see 获取素材列表
+ * @see
+ * 获取素材列表
*/
- public MediaRecord listMaterialMedia(MediaType mediaType, Pageable pageable)
- throws WeixinException {
+ public MediaRecord listMaterialMedia(MediaType mediaType, Pageable pageable) throws WeixinException {
return mediaApi.listMaterialMedia(mediaType, pageable);
}
@@ -417,8 +421,7 @@ public class WeixinProxy {
* @see {@link #listMaterialMedia(MediaType, Pageable)}
* @throws WeixinException
*/
- public List listAllMaterialMedia(MediaType mediaType)
- throws WeixinException {
+ public List listAllMaterialMedia(MediaType mediaType) throws WeixinException {
return mediaApi.listAllMaterialMedia(mediaType);
}
@@ -444,8 +447,9 @@ public class WeixinProxy {
* 客服账号 可为空
* @throws WeixinException
* @return 处理结果
- * @see 发送客服消息
+ * @see
+ * 发送客服消息
* @see com.foxinmy.weixin4j.tuple.Text
* @see com.foxinmy.weixin4j.tuple.Image
* @see com.foxinmy.weixin4j.tuple.Voice
@@ -454,8 +458,7 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.tuple.News
* @see com.foxinmy.weixin4j.mp.api.NotifyApi
*/
- public JsonResult sendNotify(NotifyMessage notify, String kfAccount)
- throws WeixinException {
+ public JsonResult sendNotify(NotifyMessage notify, String kfAccount) throws WeixinException {
return notifyApi.sendNotify(notify, kfAccount);
}
@@ -471,12 +474,12 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.model.CustomRecord
* @see com.foxinmy.weixin4j.mp.api.CustomApi
* @see 查询客服聊天记录
- * @see 查询客服聊天记录
+ * @see
+ * 查询客服聊天记录
* @throws WeixinException
*/
- public List getCustomRecord(Date startTime, Date endTime,
- Pageable pageable) throws WeixinException {
+ public List getCustomRecord(Date startTime, Date endTime, Pageable pageable) throws WeixinException {
return customApi.getCustomRecord(startTime, endTime, pageable);
}
@@ -490,15 +493,16 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.model.KfAccount
* @see com.foxinmy.weixin4j.mp.api.CustomApi
* @see 获取客服基本信息
- * @see 获取客服基本信息
+ * @see
+ * 获取客服基本信息
* @see 获取在线客服接待信息
- * @see 获取在线客服接待信息
+ * @see
+ * 获取在线客服接待信息
* @throws WeixinException
*/
- public List listKfAccount(boolean isOnline)
- throws WeixinException {
+ public List listKfAccount(boolean isOnline) throws WeixinException {
return customApi.listKfAccount(isOnline);
}
@@ -515,13 +519,14 @@ public class WeixinProxy {
* @return 处理结果
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.CustomApi
- * @see 客服管理接口返回码
- * @see 新增客服账号
+ * @see
+ * 客服管理接口返回码
+ * @see
+ * 新增客服账号
*/
- public JsonResult createAccount(String id, String name, String pwd)
- throws WeixinException {
+ public JsonResult createAccount(String id, String name, String pwd) throws WeixinException {
return customApi.createAccount(id, name, pwd);
}
@@ -538,13 +543,14 @@ public class WeixinProxy {
* @return 处理结果
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.CustomApi
- * @see 客服管理接口返回码
- * @see 新增客服账号
+ * @see
+ * 客服管理接口返回码
+ * @see
+ * 新增客服账号
*/
- public JsonResult updateAccount(String id, String name, String pwd)
- throws WeixinException {
+ public JsonResult updateAccount(String id, String name, String pwd) throws WeixinException {
return customApi.updateAccount(id, name, pwd);
}
@@ -560,13 +566,14 @@ public class WeixinProxy {
* @return 处理结果
* @see com.foxinmy.weixin4j.mp.api.CustomApi
* @throws WeixinException
- * @see 客服管理接口返回码
- * @see 上传客服头像
+ * @see
+ * 客服管理接口返回码
+ * @see
+ * 上传客服头像
*/
- public JsonResult uploadAccountHeadimg(String accountId, InputStream is,
- String fileName) throws WeixinException {
+ public JsonResult uploadAccountHeadimg(String accountId, InputStream is, String fileName) throws WeixinException {
return customApi.uploadAccountHeadimg(accountId, is, fileName);
}
@@ -578,10 +585,12 @@ public class WeixinProxy {
* @return 处理结果
* @see com.foxinmy.weixin4j.mp.api.CustomApi
* @throws WeixinException
- * @see 客服管理接口返回码
- * @see 删除客服账号
+ * @see
+ * 客服管理接口返回码
+ * @see
+ * 删除客服账号
*/
public JsonResult deleteAccount(String id) throws WeixinException {
return customApi.deleteAccount(id);
@@ -603,11 +612,11 @@ public class WeixinProxy {
* @return 处理结果
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.CustomApi
- * @see 创建会话
+ * @see
+ * 创建会话
*/
- public JsonResult createKfSession(String userOpenId, String kfAccount,
- String text) throws WeixinException {
+ public JsonResult createKfSession(String userOpenId, String kfAccount, String text) throws WeixinException {
return customApi.createKfSession(userOpenId, kfAccount, text);
}
@@ -623,11 +632,11 @@ public class WeixinProxy {
* @return 处理结果
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.CustomApi
- * @see 创建会话
+ * @see
+ * 创建会话
*/
- public JsonResult closeKfSession(String userOpenId, String kfAccount,
- String text) throws WeixinException {
+ public JsonResult closeKfSession(String userOpenId, String kfAccount, String text) throws WeixinException {
return customApi.closeKfSession(userOpenId, kfAccount, text);
}
@@ -640,8 +649,9 @@ public class WeixinProxy {
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.CustomApi
* @see com.foxinmy.weixin4j.mp.model.KfSession
- * @see 获取会话状态
+ * @see
+ * 获取会话状态
*/
public KfSession getKfSession(String userOpenId) throws WeixinException {
return customApi.getKfSession(userOpenId);
@@ -656,24 +666,25 @@ public class WeixinProxy {
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.CustomApi
* @see com.foxinmy.weixin4j.mp.model.KfSession
- * @see 获取客服的会话列表
+ * @see
+ * 获取客服的会话列表
*/
- public List listKfSession(String kfAccount)
- throws WeixinException {
+ public List listKfSession(String kfAccount) throws WeixinException {
return customApi.listKfSession(kfAccount);
}
/**
- * 获取未接入会话列表:获取当前正在等待队列中的会话列表,此接口最多返回最早进入队列的100个未接入会话。 缺陷:没有count字段
+ * 获取未接入会话列表:获取当前正在等待队列中的会话列表,此接口最多返回最早进入队列的100个未接入会话。
+ * 缺陷:没有count字段
*
* @return 会话列表
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.CustomApi
* @see com.foxinmy.weixin4j.mp.model.KfSession
- * @see 获取客服的会话列表
+ * @see
+ * 获取客服的会话列表
*/
public List listKfSessionWait() throws WeixinException {
return customApi.listKfSessionWait();
@@ -686,13 +697,13 @@ public class WeixinProxy {
* 图片消息
* @return 媒体ID
* @throws WeixinException
- * @see 上传图文素材
+ * @see
+ * 上传图文素材
* @see com.foxinmy.weixin4j.tuple.MpArticle
* @see com.foxinmy.weixin4j.mp.api.MassApi
*/
- public String uploadMassArticle(List articles)
- throws WeixinException {
+ public String uploadMassArticle(List articles) throws WeixinException {
return massApi.uploadArticle(articles);
}
@@ -721,11 +732,11 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.api.MassApi
* @see com.foxinmy.weixin4j.tuple.MassTuple
* @see {@link com.foxinmy.weixin4j.mp.api.GroupApi#getGroups()}
- * @see 根据分组群发
+ * @see
+ * 根据分组群发
*/
- public String[] massByGroupId(MassTuple tuple, boolean isToAll, int groupId)
- throws WeixinException {
+ public String[] massByGroupId(MassTuple tuple, boolean isToAll, int groupId) throws WeixinException {
return massApi.massByGroupId(tuple, isToAll, groupId);
}
@@ -738,13 +749,13 @@ public class WeixinProxy {
* 分组ID
* @return 第一个元素为消息发送任务的ID,第二个元素为消息的数据ID,该字段只有在群发图文消息时,才会出现,可以用于在图文分析数据接口中
* @see {@link #massByGroupId(Tuple,int)}
- * @see 根据分组群发
+ * @see
+ * 根据分组群发
* @see com.foxinmy.weixin4j.tuple.MpArticle
* @throws WeixinException
*/
- public String[] massArticleByGroupId(List articles, int groupId)
- throws WeixinException {
+ public String[] massArticleByGroupId(List articles, int groupId) throws WeixinException {
return massApi.massArticleByGroupId(articles, groupId);
}
@@ -770,13 +781,13 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.tuple.MpNews
* @see com.foxinmy.weixin4j.mp.api.MassApi
* @see com.foxinmy.weixin4j.tuple.MassTuple
- * @see 根据openid群发
+ * @see
+ * 根据openid群发
* @see {@link com.foxinmy.weixin4j.mp.api.MediaApi#uploadMedia(File)}
* @see {@link com.foxinmy.weixin4j.mp.api.UserApi#getUser(String)}
*/
- public String[] massByOpenIds(MassTuple tuple, String... openIds)
- throws WeixinException {
+ public String[] massByOpenIds(MassTuple tuple, String... openIds) throws WeixinException {
return massApi.massByOpenIds(tuple, openIds);
}
@@ -788,14 +799,14 @@ public class WeixinProxy {
* @param openIds
* openId列表
* @return 第一个元素为消息发送任务的ID,第二个元素为消息的数据ID,该字段只有在群发图文消息时,才会出现,可以用于在图文分析数据接口中
- * @see 根据openid群发
+ * @see
+ * 根据openid群发
* @see {@link #massByOpenIds(Tuple,String...)}
* @see com.foxinmy.weixin4j.tuple.MpArticle
* @throws WeixinException
*/
- public String[] massArticleByOpenIds(List articles,
- String... openIds) throws WeixinException {
+ public String[] massArticleByOpenIds(List articles, String... openIds) throws WeixinException {
return massApi.massArticleByOpenIds(articles, openIds);
}
@@ -808,18 +819,21 @@ public class WeixinProxy {
* @param msgid
* 发送出去的消息ID
* @throws WeixinException
- * @see 删除群发
+ * @see
+ * 删除群发
* @see com.foxinmy.weixin4j.mp.api.MassApi
* @see {@link #massByGroupId(Tuple, int)}
- * @see {@link #massByOpenIds(Tuple, String...)
+ * @see {@link #massByOpenIds(Tuple, String...)
+ *
*/
public JsonResult deleteMassNews(String msgid) throws WeixinException {
return massApi.deleteMassNews(msgid);
}
/**
- * 预览群发消息 开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版
+ * 预览群发消息
+ * 开发者可通过该接口发送消息给指定用户,在手机端查看消息的样式和排版
*
* @param toUser
* 接收用户的openID
@@ -831,11 +845,11 @@ public class WeixinProxy {
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MassApi
* @see com.foxinmy.weixin4j.tuple.MassTuple
- * @see 预览群发消息
+ * @see
+ * 预览群发消息
*/
- public JsonResult previewMassNews(String toUser, String toWxName,
- MassTuple tuple) throws WeixinException {
+ public JsonResult previewMassNews(String toUser, String toWxName, MassTuple tuple) throws WeixinException {
return massApi.previewMassNews(toUser, toWxName, tuple);
}
@@ -847,8 +861,9 @@ public class WeixinProxy {
* @return 消息发送状态
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.api.MassApi
- * @see 查询群发状态
+ * @see
+ * 查询群发状态
*/
public String getMassNewStatus(String msgId) throws WeixinException {
return massApi.getMassNewStatus(msgId);
@@ -861,8 +876,9 @@ public class WeixinProxy {
* 用户对应的ID
* @return 用户对象
* @throws WeixinException
- * @see 获取用户信息
+ * @see
+ * 获取用户信息
* @see com.foxinmy.weixin4j.mp.model.User
* @see com.foxinmy.weixin4j.mp.api.UserApi
* @see {@link #getUser(String,Lang)}
@@ -884,8 +900,9 @@ public class WeixinProxy {
* 国家地区语言版本
* @return 用户对象
* @throws WeixinException
- * @see 获取用户信息
+ * @see
+ * 获取用户信息
* @see com.foxinmy.weixin4j.mp.type.Lang
* @see com.foxinmy.weixin4j.mp.model.User
* @see com.foxinmy.weixin4j.mp.api.UserApi
@@ -900,8 +917,9 @@ public class WeixinProxy {
* @param openIds
* 用户ID
* @return 用户列表
- * @see 获取用户信息
+ * @see
+ * 获取用户信息
* @see com.foxinmy.weixin4j.mp.model.User
* @see com.foxinmy.weixin4j.mp.api.UserApi
* @throws WeixinException
@@ -919,36 +937,58 @@ public class WeixinProxy {
* @param openIds
* 用户ID
* @return 用户列表
- * @see 获取用户信息
+ * @see
+ * 获取用户信息
* @see com.foxinmy.weixin4j.mp.type.Lang
* @see com.foxinmy.weixin4j.mp.model.User
* @see com.foxinmy.weixin4j.mp.api.UserApi
* @throws WeixinException
*/
- public List getUsers(Lang lang, String... openIds)
- throws WeixinException {
+ public List getUsers(Lang lang, String... openIds) throws WeixinException {
return userApi.getUsers(lang, openIds);
}
/**
- * 获取用户一定数量(10000)的关注者列表
+ * 获取公众号一定数量(10000)的关注者列表 请慎重使用
*
* @param nextOpenId
- * 第一个拉取的OPENID,不填默认从头开始拉取
- * @return 关注信息
+ * 下一次拉取数据的openid 不填写则默认从头开始拉取
+ * @return 关注者信息 包含用户的详细信息
* @throws WeixinException
- * @see 获取关注者列表
- * @see com.foxinmy.weixin4j.mp.model.Following
+ * @see
+ * 获取关注者列表
+ * @see
+ * 批量获取用户信息
* @see com.foxinmy.weixin4j.mp.api.UserApi
+ * @see com.foxinmy.weixin4j.mp.model.Following
+ * @see com.foxinmy.weixin4j.mp.model.User
*/
public Following getFollowing(String nextOpenId) throws WeixinException {
return userApi.getFollowing(nextOpenId);
}
/**
- * 获取用户全部的关注者列表
+ * 获取公众号一定数量(10000)的关注者列表
+ *
+ * @param nextOpenId
+ * 下一次拉取数据的openid 不填写则默认从头开始拉取
+ * @return 关注者信息 不包含用户的详细信息
+ * @throws WeixinException
+ * @see
+ * 获取关注者列表
+ * @see com.foxinmy.weixin4j.mp.api.UserApi
+ * @see com.foxinmy.weixin4j.mp.model.Following
+ */
+ public Following getFollowingOpenIds(String nextOpenId) throws WeixinException {
+ return userApi.getFollowingOpenIds(nextOpenId);
+ }
+
+ /**
+ * 获取公众号全部的关注者列表 请慎重使用
*
* 当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求,
* 将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值
@@ -956,16 +996,40 @@ public class WeixinProxy {
*
* @return 用户对象集合
* @throws WeixinException
- * @see 获取关注者列表
- * @see com.foxinmy.weixin4j.mp.model.Following
+ * @see
+ * 获取关注者列表
+ * @see
+ * 批量获取用户信息
* @see com.foxinmy.weixin4j.mp.api.UserApi
- * @see {@link #getFollowing(String)}
+ * @see com.foxinmy.weixin4j.mp.model.Following
+ * @see com.foxinmy.weixin4j.mp.model.User
+ * @see com.foxinmy.weixin4j.mp.WeixinProxy#getFollowing(String)
*/
public List getAllFollowing() throws WeixinException {
return userApi.getAllFollowing();
}
+ /**
+ * 获取公众号全部的关注者列表 请慎重使用
+ *
+ * 当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求,
+ * 将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值
+ *
+ *
+ * @return 用户openid集合
+ * @throws WeixinException
+ * @see
+ * 获取关注者列表
+ * @see com.foxinmy.weixin4j.mp.api.UserApi
+ * @see com.foxinmy.weixin4j.mp.WeixinProxy#getFollowingOpenIds(String)
+ */
+ public List getAllFollowingOpenIds() throws WeixinException {
+ return userApi.getAllFollowingOpenIds();
+ }
+
/**
* 设置用户备注名
*
@@ -974,12 +1038,12 @@ public class WeixinProxy {
* @param remark
* 备注名
* @throws WeixinException
- * @see 设置用户备注名
+ * @see
+ * 设置用户备注名
* @see com.foxinmy.weixin4j.mp.api.UserApi
*/
- public JsonResult remarkUserName(String openId, String remark)
- throws WeixinException {
+ public JsonResult remarkUserName(String openId, String remark) throws WeixinException {
return userApi.remarkUserName(openId, remark);
}
@@ -990,8 +1054,9 @@ public class WeixinProxy {
* 组名称
* @return group对象
* @throws WeixinException
- * @see 创建分组
+ * @see
+ * 创建分组
* @see com.foxinmy.weixin4j.mp.model.Group
* @see com.foxinmy.weixin4j.mp.model.Group#toCreateJson()
* @see com.foxinmy.weixin4j.mp.api.GroupApi
@@ -1005,8 +1070,9 @@ public class WeixinProxy {
*
* @return 组集合
* @throws WeixinException
- * @see 查询所有分组
+ * @see
+ * 查询所有分组
* @see com.foxinmy.weixin4j.mp.model.Group
* @see com.foxinmy.weixin4j.mp.api.GroupApi
*/
@@ -1021,8 +1087,9 @@ public class WeixinProxy {
* 用户对应的ID
* @return 组ID
* @throws WeixinException
- * @see 查询用户所在分组
+ * @see
+ * 查询用户所在分组
* @see com.foxinmy.weixin4j.mp.model.Group
* @see com.foxinmy.weixin4j.mp.api.GroupApi
*/
@@ -1038,13 +1105,13 @@ public class WeixinProxy {
* @param name
* 组名称
* @throws WeixinException
- * @see 修改分组名
+ * @see
+ * 修改分组名
* @see com.foxinmy.weixin4j.mp.model.Group
* @see com.foxinmy.weixin4j.mp.api.GroupApi
*/
- public JsonResult modifyGroup(int groupId, String name)
- throws WeixinException {
+ public JsonResult modifyGroup(int groupId, String name) throws WeixinException {
return groupApi.modifyGroup(groupId, name);
}
@@ -1056,13 +1123,13 @@ public class WeixinProxy {
* @param openId
* 用户对应的ID
* @throws WeixinException
- * @see 移动分组
+ * @see
+ * 移动分组
* @see com.foxinmy.weixin4j.mp.model.Group
* @see com.foxinmy.weixin4j.mp.api.GroupApi
*/
- public JsonResult moveGroup(int groupId, String openId)
- throws WeixinException {
+ public JsonResult moveGroup(int groupId, String openId) throws WeixinException {
return groupApi.moveGroup(groupId, openId);
}
@@ -1074,13 +1141,13 @@ public class WeixinProxy {
* @param openIds
* 用户ID列表(不能超过50个)
* @throws WeixinException
- * @see 批量移动分组
+ * @see
+ * 批量移动分组
* @see com.foxinmy.weixin4j.mp.model.Group
* @see com.foxinmy.weixin4j.mp.api.GroupApi
*/
- public JsonResult moveGroup(int groupId, String... openIds)
- throws WeixinException {
+ public JsonResult moveGroup(int groupId, String... openIds) throws WeixinException {
return groupApi.moveGroup(groupId, openIds);
}
@@ -1090,8 +1157,9 @@ public class WeixinProxy {
* @param groupId
* 组ID
* @throws WeixinException
- * @see 删除用户分组
+ * @see
+ * 删除用户分组
* @see com.foxinmy.weixin4j.mp.model.Group
* @see com.foxinmy.weixin4j.mp.api.GroupApi
*/
@@ -1105,8 +1173,9 @@ public class WeixinProxy {
* @param buttons
* 菜单列表
* @throws WeixinException
- * @see 创建自定义菜单
+ * @see
+ * 创建自定义菜单
* @see com.foxinmy.weixin4j.model.Button
* @see com.foxinmy.weixin4j.type.ButtonType
* @see com.foxinmy.weixin4j.mp.api.MenuApi
@@ -1120,8 +1189,9 @@ public class WeixinProxy {
*
* @return 菜单集合
* @throws WeixinException
- * @see 查询菜单
+ * @see
+ * 查询菜单
* @see com.foxinmy.weixin4j.model.Button
* @see com.foxinmy.weixin4j.mp.api.MenuApi
*/
@@ -1134,10 +1204,12 @@ public class WeixinProxy {
*
* @return 菜单集合
* @throws WeixinException
- * @see 查询菜单
- * @see 个性化菜单
+ * @see
+ * 查询菜单
+ * @see
+ * 个性化菜单
* @see com.foxinmy.weixin4j.model.Button
* @see com.foxinmy.weixin4j.mp.model.Menu
* @see com.foxinmy.weixin4j.mp.api.MenuApi
@@ -1150,8 +1222,9 @@ public class WeixinProxy {
* 删除菜单
*
* @throws WeixinException
- * @see 删除菜单
+ * @see
+ * 删除菜单
* @see com.foxinmy.weixin4j.mp.api.MenuApi
*/
public JsonResult deleteMenu() throws WeixinException {
@@ -1162,8 +1235,9 @@ public class WeixinProxy {
* 删除个性化菜单
*
* @throws WeixinException
- * @see 删除个性化菜单
+ * @see
+ * 删除个性化菜单
* @see com.foxinmy.weixin4j.mp.api.MenuApi
* @return 处理结果
*/
@@ -1177,8 +1251,9 @@ public class WeixinProxy {
* @param userId
* 可以是粉丝的OpenID,也可以是粉丝的微信号。
* @return 匹配到的菜单配置
- * @see 测试个性化菜单
+ * @see
+ * 测试个性化菜单
* @see com.foxinmy.weixin4j.model.Button
* @see com.foxinmy.weixin4j.mp.api.MenuApi
* @throws WeixinException
@@ -1197,8 +1272,9 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.model.QRResult
* @see com.foxinmy.weixin4j.mp.model.QRParameter
* @see com.foxinmy.weixin4j.mp.api.QrApi
- * @see 生成二维码
+ * @see
+ * 生成二维码
*/
public QRResult createQR(QRParameter parameter) throws WeixinException {
return qrApi.createQR(parameter);
@@ -1213,11 +1289,11 @@ public class WeixinProxy {
* @throws WeixinException
* @see com.foxinmy.weixin4j.mp.type.IndustryType
* @see com.foxinmy.weixin4j.mp.api.TmplApi
- * @see 设置所处行业
+ * @see
+ * 设置所处行业
*/
- public JsonResult setTmplIndustry(IndustryType... industryTypes)
- throws WeixinException {
+ public JsonResult setTmplIndustry(IndustryType... industryTypes) throws WeixinException {
return tmplApi.setTmplIndustry(industryTypes);
}
@@ -1228,8 +1304,9 @@ public class WeixinProxy {
* 模板库中模板的编号,有“TM**”和“OPENTMTM**”等形式
* @return 模板ID
* @throws WeixinException
- * @see 获得模板ID
+ * @see
+ * 获得模板ID
* @see com.foxinmy.weixin4j.mp.api.TmplApi
*/
public String getTemplateId(String shortId) throws WeixinException {
@@ -1241,8 +1318,9 @@ public class WeixinProxy {
*
* @return 模板列表
* @see com.foxinmy.weixin4j.mp.model.TemplateMessageInfo
- * @see 获取模板列表
+ * @see
+ * 获取模板列表
* @see com.foxinmy.weixin4j.mp.api.TmplApi
* @throws WeixinException
*/
@@ -1256,8 +1334,9 @@ public class WeixinProxy {
* @param templateId
* 公众帐号下模板消息ID
* @return 处理结果
- * @see 删除模板
+ * @see
+ * 删除模板
* @see com.foxinmy.weixin4j.mp.api.TmplApi
* @throws WeixinException
*/
@@ -1272,14 +1351,14 @@ public class WeixinProxy {
* 模板消息主体
* @return 发送结果
* @throws WeixinException
- * @see 模板消息
+ * @see
+ * 模板消息
* @see com.foxinmy.weixin4j.mp.message.TemplateMessage
* @seee com.foxinmy.weixin4j.msg.event.TemplatesendjobfinishMessage
* @see com.foxinmy.weixin4j.mp.api.TmplApi
*/
- public JsonResult sendTmplMessage(TemplateMessage tplMessage)
- throws WeixinException {
+ public JsonResult sendTmplMessage(TemplateMessage tplMessage) throws WeixinException {
return tmplApi.sendTmplMessage(tplMessage);
}
@@ -1290,8 +1369,9 @@ public class WeixinProxy {
* 待转换的链接
* @return 短链接
* @throws WeixinException
- * @see 长链接转短链接
+ * @see
+ * 长链接转短链接
* @see com.foxinmy.weixin4j.mp.api.HelperApi
*/
public String getShorturl(String url) throws WeixinException {
@@ -1306,8 +1386,9 @@ public class WeixinProxy {
* @return 语义理解结果
* @see com.foxinmy.weixin4j.mp.model.SemQuery
* @see com.foxinmy.weixin4j.mp.model.SemResult
- * @see 语义理解
+ * @see
+ * 语义理解
* @see com.foxinmy.weixin4j.mp.api.HelperApi
* @throws WeixinException
*/
@@ -1319,8 +1400,9 @@ public class WeixinProxy {
* 获取微信服务器IP地址
*
* @return IP地址
- * @see 获取IP地址
+ * @see
+ * 获取IP地址
* @see com.foxinmy.weixin4j.mp.api.HelperApi
* @throws WeixinException
*/
@@ -1334,8 +1416,9 @@ public class WeixinProxy {
*
* @return 菜单集合
* @see {@link #getMenu()}
- * @see 获取自定义菜单配置
+ * @see
+ * 获取自定义菜单配置
* @see com.foxinmy.weixin4j.model.Button
* @se com.foxinmy.weixin4j.mp.model.MenuSetting
* @see com.foxinmy.weixin4j.tuple.MpArticle
@@ -1351,8 +1434,9 @@ public class WeixinProxy {
*
* @see com.foxinmy.weixin4j.mp.model.AutoReplySetting
* @see com.foxinmy.weixin4j.mp.api.HelperApi
- * @see 获取自动回复规则
+ * @see
+ * 获取自动回复规则
* @throws WeixinException
*/
public AutoReplySetting getAutoReplySetting() throws WeixinException {
@@ -1378,18 +1462,21 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.datacube.UpstreamMsgDist
* @see com.foxinmy.weixin4j.mp.datacube.InterfaceSummary
* @return 统计结果
- * @see 用户分析
- * @see 图文分析
- * @see 消息分析
- * @see 接口分析
+ * @see
+ * 用户分析
+ * @see
+ * 图文分析
+ * @see
+ * 消息分析
+ * @see
+ * 接口分析
* @throws WeixinException
*/
- public List> datacube(DatacubeType datacubeType, Date beginDate,
- Date endDate) throws WeixinException {
+ public List> datacube(DatacubeType datacubeType, Date beginDate, Date endDate) throws WeixinException {
return dataApi.datacube(datacubeType, beginDate, endDate);
}
@@ -1406,8 +1493,7 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.api.DataApi
* @throws WeixinException
*/
- public List> datacube(DatacubeType datacubeType, Date beginDate,
- int offset) throws WeixinException {
+ public List> datacube(DatacubeType datacubeType, Date beginDate, int offset) throws WeixinException {
return dataApi.datacube(datacubeType, beginDate, offset);
}
@@ -1424,8 +1510,7 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.api.DataApi
* @throws WeixinException
*/
- public List> datacube(DatacubeType datacubeType, int offset, Date endDate)
- throws WeixinException {
+ public List> datacube(DatacubeType datacubeType, int offset, Date endDate) throws WeixinException {
return dataApi.datacube(datacubeType, offset, endDate);
}
@@ -1440,8 +1525,7 @@ public class WeixinProxy {
* @see com.foxinmy.weixin4j.mp.api.DataApi
* @throws WeixinException
*/
- public List> datacube(DatacubeType datacubeType, Date date)
- throws WeixinException {
+ public List> datacube(DatacubeType datacubeType, Date date) throws WeixinException {
return dataApi.datacube(datacubeType, date);
}
diff --git a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/api/UserApi.java b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/api/UserApi.java
index 28153fb8..5968e7d6 100644
--- a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/api/UserApi.java
+++ b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/api/UserApi.java
@@ -58,16 +58,17 @@ public class UserApi extends MpApi {
* 国家地区语言版本
* @return 用户对象
* @throws WeixinException
- * @see 获取用户信息
+ * @see
+ * 获取用户信息
* @see com.foxinmy.weixin4j.mp.type.Lang
* @see com.foxinmy.weixin4j.mp.model.User
*/
public User getUser(String openId, Lang lang) throws WeixinException {
String user_info_uri = getRequestUri("api_user_info_uri");
Token token = tokenHolder.getToken();
- WeixinResponse response = weixinExecutor.get(String.format(
- user_info_uri, token.getAccessToken(), openId, lang.name()));
+ WeixinResponse response = weixinExecutor
+ .get(String.format(user_info_uri, token.getAccessToken(), openId, lang.name()));
return response.getAsObject(new TypeReference() {
});
@@ -79,8 +80,9 @@ public class UserApi extends MpApi {
* @param openIds
* 用户ID
* @return 用户列表
- * @see 获取用户信息
+ * @see
+ * 获取用户信息
* @see com.foxinmy.weixin4j.mp.model.User
* @throws WeixinException
* @see {@link #getUsers(Lang,String[])}
@@ -95,71 +97,89 @@ public class UserApi extends MpApi {
* @param lang
* 国家地区语言版本
* @param openIds
- * 用户ID
+ * 用户ID 最多100个
* @return 用户列表
- * @see 获取用户信息
+ * @see
+ * 获取用户信息
* @see com.foxinmy.weixin4j.mp.type.Lang
* @see com.foxinmy.weixin4j.mp.model.User
* @throws WeixinException
*/
- public List getUsers(Lang lang, String... openIds)
- throws WeixinException {
+ public List getUsers(Lang lang, String... openIds) throws WeixinException {
String api_users_info_uri = getRequestUri("api_users_info_uri");
StringBuilder parameter = new StringBuilder();
parameter.append("{\"user_list\": [");
for (String openId : openIds) {
parameter.append("{\"openid\": \"").append(openId).append("\"");
- parameter.append(",\"lang\": \"").append(lang.name()).append("\"")
- .append("},");
+ parameter.append(",\"lang\": \"").append(lang.name()).append("\"").append("},");
}
parameter.delete(parameter.length() - 1, parameter.length());
parameter.append("]}");
Token token = tokenHolder.getToken();
- WeixinResponse response = weixinExecutor.post(
- String.format(api_users_info_uri, token.getAccessToken()),
+ WeixinResponse response = weixinExecutor.post(String.format(api_users_info_uri, token.getAccessToken()),
parameter.toString());
- return JSON.parseArray(
- response.getAsJson().getString("user_info_list"), User.class);
+ return JSON.parseArray(response.getAsJson().getString("user_info_list"), User.class);
}
/**
- * 获取用户一定数量(10000)的关注者列表
+ * 获取公众号一定数量(10000)的关注者列表 请慎重使用
*
* @param nextOpenId
- * 下一次拉取数据的openid
- * @return 关注信息
+ * 下一次拉取数据的openid 不填写则默认从头开始拉取
+ * @return 关注者信息 包含用户的详细信息
* @throws WeixinException
- * @see 获取关注者列表
+ * @see
+ * 获取关注者列表
+ * @see
+ * 批量获取用户信息
* @see com.foxinmy.weixin4j.mp.model.Following
+ * @see com.foxinmy.weixin4j.mp.model.User
*/
public Following getFollowing(String nextOpenId) throws WeixinException {
- String following_uri = getRequestUri("following_uri");
- Token token = tokenHolder.getToken();
- WeixinResponse response = weixinExecutor.get(String.format(
- following_uri, token.getAccessToken(), nextOpenId == null ? ""
- : nextOpenId));
-
- Following following = response
- .getAsObject(new TypeReference() {
- });
-
+ Following following = getFollowingOpenIds(nextOpenId);
if (following.getCount() > 0) {
- List openIds = JSON.parseArray(following.getDataJson()
- .getString("openid"), String.class);
- List userList = new ArrayList();
- for (String openId : openIds) {
- userList.add(getUser(openId));
+ List users = new ArrayList(following.getCount());
+ for (int i = 1; i <= (int) Math.ceil(following.getCount() / 100d); i++) {
+ users.addAll(getUsers(following.getOpenIds().subList((i - 1) * 100, i * 100).toArray(new String[] {})));
}
- following.setUserList(userList);
+ following.setUserList(users);
}
return following;
}
/**
- * 获取用户全部的关注者列表
+ * 获取公众号一定数量(10000)的关注者列表
+ *
+ * @param nextOpenId
+ * 下一次拉取数据的openid 不填写则默认从头开始拉取
+ * @return 关注者信息 不包含用户的详细信息
+ * @throws WeixinException
+ * @see
+ * 获取关注者列表
+ * @see com.foxinmy.weixin4j.mp.model.Following
+ */
+ public Following getFollowingOpenIds(String nextOpenId) throws WeixinException {
+ String following_uri = getRequestUri("following_uri");
+ Token token = tokenHolder.getToken();
+ WeixinResponse response = weixinExecutor
+ .get(String.format(following_uri, token.getAccessToken(), nextOpenId == null ? "" : nextOpenId));
+
+ JSONObject result = response.getAsJson();
+ Following following = JSON.toJavaObject(result, Following.class);
+
+ if (following.getCount() > 0) {
+ following.setOpenIds(JSON.parseArray(result.getJSONObject("data").getString("openid"), String.class));
+ }
+ return following;
+ }
+
+ /**
+ * 获取公众号全部的关注者列表 请慎重使用
*
* 当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求,
* 将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值
@@ -167,9 +187,13 @@ public class UserApi extends MpApi {
*
* @return 用户对象集合
* @throws WeixinException
- * @see 获取关注者列表
- * @see com.foxinmy.weixin4j.mp.model.Following
+ * @see
+ * 获取关注者列表
+ * @see
+ * 批量获取用户信息
+ * @see com.foxinmy.weixin4j.mp.model.User
* @see com.foxinmy.weixin4j.mp.api.UserApi#getFollowing(String)
*/
public List getAllFollowing() throws WeixinException {
@@ -187,6 +211,35 @@ public class UserApi extends MpApi {
return userList;
}
+ /**
+ * 获取公众号全部的关注者列表 请慎重使用
+ *
+ * 当公众号关注者数量超过10000时,可通过填写next_openid的值,从而多次拉取列表的方式来满足需求,
+ * 将上一次调用得到的返回中的next_openid值,作为下一次调用中的next_openid值
+ *
+ *
+ * @return 用户openid集合
+ * @throws WeixinException
+ * @see
+ * 获取关注者列表
+ * @see com.foxinmy.weixin4j.mp.api.UserApi#getFollowingOpenIds(String)
+ */
+ public List getAllFollowingOpenIds() throws WeixinException {
+ List openIds = new ArrayList();
+ String nextOpenId = null;
+ Following f = null;
+ for (;;) {
+ f = getFollowingOpenIds(nextOpenId);
+ if (f.getCount() == 0) {
+ break;
+ }
+ openIds.addAll(f.getOpenIds());
+ nextOpenId = f.getNextOpenId();
+ }
+ return openIds;
+ }
+
/**
* 设置用户备注名
*
@@ -195,18 +248,17 @@ public class UserApi extends MpApi {
* @param remark
* 备注名
* @throws WeixinException
- * @see 设置用户备注名
+ * @see
+ * 设置用户备注名
*/
- public JsonResult remarkUserName(String openId, String remark)
- throws WeixinException {
+ public JsonResult remarkUserName(String openId, String remark) throws WeixinException {
String updateremark_uri = getRequestUri("updateremark_uri");
Token token = tokenHolder.getToken();
JSONObject obj = new JSONObject();
obj.put("openid", openId);
obj.put("remark", remark);
- WeixinResponse response = weixinExecutor.post(
- String.format(updateremark_uri, token.getAccessToken()),
+ WeixinResponse response = weixinExecutor.post(String.format(updateremark_uri, token.getAccessToken()),
obj.toJSONString());
return response.getAsJsonResult();
diff --git a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/model/Following.java b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/model/Following.java
index a23ace51..c49b0a75 100644
--- a/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/model/Following.java
+++ b/weixin4j-mp/src/main/java/com/foxinmy/weixin4j/mp/model/Following.java
@@ -3,7 +3,6 @@ package com.foxinmy.weixin4j.mp.model;
import java.io.Serializable;
import java.util.List;
-import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
/**
@@ -28,8 +27,8 @@ public class Following implements Serializable {
/**
* 列表数据,OPENID的列表
*/
- @JSONField(name = "data")
- private JSONObject dataJson;
+ @JSONField(deserialize = false)
+ private List openIds;
/**
* 拉取列表的后一个用户的OPENID
*/
@@ -40,6 +39,7 @@ public class Following implements Serializable {
*
* @see com.foxinmy.weixin4j.mp.model.User
*/
+ @JSONField(deserialize = false)
private List userList;
public int getTotal() {
@@ -66,12 +66,12 @@ public class Following implements Serializable {
this.userList = userList;
}
- public JSONObject getDataJson() {
- return dataJson;
+ public List getOpenIds() {
+ return openIds;
}
- public void setDataJson(JSONObject dataJson) {
- this.dataJson = dataJson;
+ public void setOpenIds(List openIds) {
+ this.openIds = openIds;
}
public String getNextOpenId() {
@@ -84,17 +84,7 @@ public class Following implements Serializable {
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("[Following total=").append(total);
- sb.append(", count=").append(count);
- if (userList != null && !userList.isEmpty()) {
- sb.append(", users={");
- for (User u : userList) {
- sb.append(u.toString());
- }
- sb.append("}");
- }
- sb.append(", nextOpenId=").append(nextOpenId).append("]");
- return sb.toString();
+ return "Following [total=" + total + ", count=" + count + ", openIds=" + openIds + ", nextOpenId=" + nextOpenId
+ + ", userList=" + userList + "]";
}
}