4

这是我的代码:

int favouritesCount = user.getFavouritesCount();
int followersCount = user.getFollowersCount();
int friendsCount = user.getFriendsCount();
long userId = user.getId();
System.out.println("FavouritesCount: " + favouritesCount + ", followersCount: " + followersCount + ", friendsCount: " + friendsCount);
ArrayList<User> followers = new ArrayList<User>();
long nextCursor = 0;
do {
    PagableResponseList<User> usersResponse = twitter.getFollowersList(user.getScreenName(), nextCursor);
    System.out.println("size() of first iteration:" + usersResponse.size());
    nextCursor = usersResponse.getNextCursor();
    followers.addAll(usersResponse);
} while ( nextCursor > 0);

System.out.println( followers.size() > 0 ? "Getting followers:" : "No followers.");

for ( User user : followers) {
    System.out.println(user.getScreenName() + ", id: " + user.getId());
}

这是我得到的输出:

FavouritesCount: 0, followersCount: 1, friendsCount: 1
size() of first iteration:0
No followers.

我在这里做错了什么?用户通过 OAuth 进行身份验证,一切都很好,除了这部分代码根本不起作用。正确的是追随者和朋友的数量,但我看到追随者有问题。

请帮忙!

最好的,D

4

1 回答 1

5

我已经解决了这个问题。实际上,错误在于以下行:

long nextCursor = 0;

应该设置

long nextCursor = -1;

作为文档非常清楚地“说”:链接

再次感谢!

于 2013-05-20T09:48:38.140 回答