我正在使用Twitter4j库,我正在尝试获取经过身份验证的用户的关注者列表。
我正在执行以下操作:
IDs followersIds = mTwitter.getFollowersIDs(-1);
long [] ids = followersIds.getIDs();
List<User> followers = new ArrayList<User>();
for(int i = 0; i < ids.length; i++) {
followers.add(mTwitter.showUser(ids[i]));
}
尽管这可能有效,但它远非有效,因为它为每个关注者发送一个请求。除了这种方法缓慢之外,我最终还得到以下错误:
error - Rate limit exceeded. Clients may not make more than 350 requests per hour.
有人知道更好的方法吗? (我花了一些时间在 documentation 但找不到任何)。
谢谢!
最佳答案
UserMethods
中有一个 lookupUsers(long[] ids)
方法,您应该用于此目的。您向其传递一个最多包含 100 个用户 ID 的数组(每个请求)并获取返回的所有扩展信息。
请记住,您可能想要使用 async version of this method ,因为您可能不想在 UI 线程上执行请求。
关于android - 使用 Twitter4j 获取关注者列表的最有效方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8659209/