是什么让使用Twitter4j追随者名单的最有效的方法是什么? [英] What is the most effective way to get a list of followers using Twitter4j?

查看:205
本文介绍了是什么让使用Twitter4j追随者名单的最有效的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Twitter4j 库,我想获得认证的追随者名单用户。

I am using the Twitter4j library and I am trying to get the followers list of the authenticated user.

我做以下内容:

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]));
}

虽然这工作,它远远不是有效的,因为它发出的每个跟随一个请求。除了这种方法的缓慢,我最终得到了以下错误:

Although this may work, it's far from being effective since it sends one request for each follower. Besides the slowness of this method, I ultimately get the following error:

错误 - 频率超过上限。客户端可能无法使超过350
  每小时的请求。

error - Rate limit exceeded. Clients may not make more than 350 requests per hour.

任何人都知道什么更好的方法来做到这一点? (我花了一些时间在文档上,但找不到任何)。

Anyone knows any better method to do this? (I spent some time on the documentation but couldn't find any).

谢谢!

推荐答案

有一个 lookupUsers(长[] IDS)方法 UserMethods 你应该使用用于这一目的。你通过它最多100个用户的ID(每个请求)的阵列,并得到所有扩展信息返回。

There is a lookupUsers(long[] ids) method in UserMethods you should use for this purpose. You pass it an array of at most 100 user ids (per request) and get all extended information returned.

记住你可能想使用这个方法的异步版本,你可能不希望做的UI线程上的请求。

Bear in mind you might want to use the async version of this method, as you probably don't want to do the requests on the UI thread.

这篇关于是什么让使用Twitter4j追随者名单的最有效的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆