【问题标题】:Retweeters of a Twitter status in TweepyTweepy 中 Twitter 状态的转发者
【发布时间】:2013-07-17 11:50:47
【问题描述】:

这是this question 的后续问题。我想获取转发特定推文的用户的 ID。

我尝试使用相同的技术,但出现错误。代码如下:

import tweepy

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)

api = tweepy.API(auth)

firstTweet = api.user_timeline("github")[0]
print firstTweet.text
print firstTweet.id
results = api.retweeted_by(firstTweet.id) 
print results

这将返回第一条推文以及推文 ID。然后它给了我以下错误:

    Traceback (most recent call last):
  File "twitter_test.py", line 21, in <module>
    results = api.retweeted_by("357237988863913984") 
  File "/usr/local/lib/python2.7/dist-packages/tweepy-2.1-py2.7.egg/tweepy/binder.py", line 197, in _call
    return method.execute()
  File "/usr/local/lib/python2.7/dist-packages/tweepy-2.1-py2.7.egg/tweepy/binder.py", line 173, in execute
    raise TweepError(error_msg, resp)
tweepy.error.TweepError: [{u'message': u'Sorry, that page does not exist', u'code': 34}]

【问题讨论】:

  • +1 为真棒标题。 (或者我应该说twitle

标签: python twitter tweepy


【解决方案1】:

retweeted_by 不是 1.1 twitter API 的一部分。切换到retweets

results = api.retweets(firstTweet.id)

仅供参考,引用自docs

获取状态/转发者/ID

返回最多 100 个用户 ID 的集合,这些用户 ID 属于拥有 转发了id参数指定的推文。

此方法提供与 GET statuses/retweets/:id 类似的数据和 替换 API v1 的 GET statuses/:id/retweeted_by/ids 方法。

【讨论】:

  • 请注意,这个速率限制要低得多,只有 15 个,所以如果您执行大量 API 调用,它可能不是最佳选择。
  • 那么,最好的方法是什么?
猜你喜欢
  • 1970-01-01
  • 2016-11-08
  • 2017-07-28
  • 2019-02-03
  • 2015-04-16
  • 2018-01-22
  • 2015-03-10
  • 2017-06-22
  • 1970-01-01
相关资源
最近更新 更多