在推文中转发推特状态



这是这个问题的后续问题。我想获得转发特定推文的用户的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}]

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

results = api.retweets(firstTweet.id)

仅供参考,引用文件:

获取状态/转发/ids

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

此方法提供与GET状态/转发/:id和取代了API v1的GET status/:id/reweeted_by/ids方法。

最新更新