【问题标题】:What is the most effective way to get a list of followers using Twitter4j?使用 Twitter4j 获取关注者列表的最有效方法是什么?
【发布时间】:2011-12-28 17:33:02
【问题描述】:

我正在使用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]));
}

虽然这可能有效,但它远非有效,因为它会为每个追随者发送一个请求。除了这种方法的缓慢之外,我最终得到以下错误:

错误 - 超出速率限制。客户的收入不得超过 350 每小时请求数。

谁知道更好的方法来做到这一点? (我在documentation 上花了一些时间,但找不到任何东西)。

谢谢!

【问题讨论】:

    标签: android twitter twitter4j


    【解决方案1】:

    UserMethods 中有一个 lookupUsers(long[] ids) 方法,您应该为此目的使用。您向它传递一个最多包含 100 个用户 ID 的数组(每个请求)并返回所有扩展信息。

    请记住,您可能想要使用 async version of this method,因为您可能不想在 UI 线程上执行请求。

    【讨论】:

      【解决方案2】:

      有方法

      PagableResponseList<User> twitter4j.api.FriendsFollowersResources.getFollowersList(long arg0, long arg1) throws TwitterException
      

      【讨论】:

        猜你喜欢
        • 2014-03-01
        • 2011-10-08
        • 2017-06-30
        • 2013-07-01
        • 2020-02-20
        • 1970-01-01
        • 2020-07-10
        • 2018-06-26
        • 1970-01-01
        相关资源
        最近更新 更多