This commit is contained in:
jinyu 2016-07-04 22:17:09 +08:00
parent 47a9eaee31
commit 49eeace7f5
4 changed files with 15 additions and 11 deletions

View File

@ -1042,10 +1042,10 @@ public class WeixinProxy {
* @return 用户对象集合
* @throws WeixinException
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN">
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN">
* 获取关注者列表</a>
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN">
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN">
* 批量获取用户信息</a>
* @see com.foxinmy.weixin4j.mp.api.UserApi
* @see com.foxinmy.weixin4j.mp.model.Following
@ -1066,7 +1066,7 @@ public class WeixinProxy {
* @return 用户openid集合
* @throws WeixinException
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN">
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN">
* 获取关注者列表</a>
* @see com.foxinmy.weixin4j.mp.api.UserApi
* @see #getFollowingOpenIds(String)

View File

@ -12,6 +12,7 @@ import com.foxinmy.weixin4j.mp.model.Following;
import com.foxinmy.weixin4j.mp.model.Tag;
import com.foxinmy.weixin4j.mp.model.User;
import com.foxinmy.weixin4j.token.TokenManager;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* 标签相关API
@ -234,7 +235,7 @@ public class TagApi extends MpApi {
Following f = null;
for (;;) {
f = getTagFollowingOpenIds(tagId, nextOpenId);
if (f.getCount() == 0) {
if (f.getCount() == 0 || StringUtil.isBlank(f.getNextOpenId())) {
break;
}
openIds.addAll(f.getOpenIds());
@ -260,7 +261,7 @@ public class TagApi extends MpApi {
Following f = null;
for (;;) {
f = getTagFollowing(tagId, nextOpenId);
if (f.getCount() == 0) {
if (f.getCount() == 0 || StringUtil.isBlank(f.getNextOpenId())) {
break;
}
userList.addAll(f.getUserList());

View File

@ -14,6 +14,7 @@ import com.foxinmy.weixin4j.mp.model.Following;
import com.foxinmy.weixin4j.mp.model.User;
import com.foxinmy.weixin4j.mp.type.Lang;
import com.foxinmy.weixin4j.token.TokenManager;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* 用户相关API
@ -199,10 +200,10 @@ public class UserApi extends MpApi {
* @return 用户对象集合
* @throws WeixinException
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN">
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN">
* 获取关注者列表</a>
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN">
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN">
* 批量获取用户信息</a>
* @see com.foxinmy.weixin4j.mp.model.User
* @see com.foxinmy.weixin4j.mp.model.Following
@ -215,7 +216,8 @@ public class UserApi extends MpApi {
for (;;) {
f = getFollowing(nextOpenId);
userList.addAll(f.getUserList());
if (f.getCount() == f.getTotal() || f.getCount() == 0) {
if (f.getCount() == f.getTotal() || f.getCount() == 0
|| StringUtil.isBlank(f.getNextOpenId())) {
break;
}
nextOpenId = f.getNextOpenId();
@ -233,7 +235,7 @@ public class UserApi extends MpApi {
* @return 用户openid集合
* @throws WeixinException
* @see <a href=
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140839&token=&lang=zh_CN">
* "https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN">
* 获取关注者列表</a>
* @see #getFollowingOpenIds(String)
*/
@ -244,7 +246,8 @@ public class UserApi extends MpApi {
for (;;) {
f = getFollowingOpenIds(nextOpenId);
openIds.addAll(f.getOpenIds());
if (f.getCount() == f.getTotal() || f.getCount() == 0) {
if (f.getCount() == f.getTotal() || f.getCount() == 0
|| StringUtil.isBlank(f.getNextOpenId())) {
break;
}
nextOpenId = f.getNextOpenId();

View File

@ -29,7 +29,7 @@ public class UserTest extends TokenTest {
@Test
public void getUser() throws WeixinException {
User user = userApi.getUser("o9Onds6fbeK0lDwD8lJt2PY1VRys");
User user = userApi.getUser("owGBftyJWx21nqKlWpI3po5K_Q9o");
Assert.assertNotNull(user);
System.out.println(user);
// following();