【问题标题】:twitter retweet user id api pythontwitter 转发用户 id api python
【发布时间】:2013-06-13 19:56:03
【问题描述】:

在 python 中使用 twitter api,我需要知道如何获取所有转发推文的人的所有用户 ID。

我去了这里:https://dev.twitter.com/docs/api/1/get/statuses/%3Aid/retweeted_by

但我不知道如何将其放入 python。

到目前为止,这是我的代码:

from twitter import *
t = Twitter(auth=OAuth(....))
twitter = t.statuses.user_timeline.snl()

twitter[0]['text']           # gets the tweet
twitter[0]['retweet_count']  # gets the number of retweets

获取所有转发用户的 ID 的下一行是什么?

【问题讨论】:

    标签: python api twitter social-networking


    【解决方案1】:

    对于 twitter API 1.1,您应该使用 retweets_of_meretweeted_by 已弃用且不起作用。

    这是一个例子:

    from twitter import *
    
    t = Twitter(auth=OAuth(...))
    
    tweets = t.statuses.user_timeline.snl()
    
    for tweet in tweets:
        retweets = t.statuses.retweets_of_me(since_id=str(tweet['id']), max_id=str(tweet['id']))
        print retweets
    

    希望对您有所帮助。

    【讨论】:

    猜你喜欢
    • 2013-06-13
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 2019-03-28
    • 2014-06-14
    • 1970-01-01
    • 2012-08-10
    • 1970-01-01
    相关资源
    最近更新 更多