【问题标题】:Twitter API bug - Tweets provides the wrong User_id. Work arounds?Twitter API 错误 - 推文提供了错误的 User_id。变通?
【发布时间】:2011-11-01 10:09:13
【问题描述】:

我正在寻找解决此已发布 Twitter API 错误的方法:http://code.google.com/p/twitter-api/issues/detail?id=214

当您获取推文时,推文会返回错误的 User_id。但是,它确实为您提供了正确的屏幕名称。

我的目标是使用 API 做两件事:

  1. 获取我的 twitter 帐户的所有关注者,这对于 ruby​​ 脚本来说是微不足道的: myfollowers = Twitter.follower_ids("justinzollars")(推特宝石) 对应这个api调用:https://dev.twitter.com/docs/api/1/get/followers/ids

  2. 仅保存来自单个用户的推文。 https://dev.twitter.com/docs/api/1/get/search

问题是第一个 api 调用返回user_ids,而推文搜索调用返回from_user_id_str(用户名)。我不想进行数以万计的 api 调用,向 Twitter 询问从 tweets search api 调用返回的每个 from_user_id_struser_id

我怎样才能有效地解决这个问题?

【问题讨论】:

    标签: ruby-on-rails ruby twitter rate-limiting


    【解决方案1】:

    就检索特定用户的推文而言,搜索 API 并不是真正的最佳工具。您应该为该任务使用用户时间线,它不会遇到搜索 API 的用户 ID 不匹配问题:https://dev.twitter.com/docs/api/1/get/statuses/user_timeline

    如果您使用的是 Search API,将 Search 中的屏幕名称转换为 Twitter 上的用户 ID 的最有效模式是使用批量用户查找,这将允许您将大约 100 个屏幕名称转换为完全混合的用户对象(完整的“真实”用户 ID):https://dev.twitter.com/docs/api/1/get/users/lookup

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-06
      • 2015-09-03
      • 2010-09-17
      • 1970-01-01
      • 2013-06-08
      • 2016-04-24
      • 2020-12-06
      • 2020-03-02
      相关资源
      最近更新 更多