在python中使用twitter api命令实现的困难 [英] difficulty using twitter api command implemention in python
问题描述
似乎没有人能够回答我的问题,我在其他帖子中也找不到.使用 twitter 的 api,我想输入推文 ID 并返回所有转发该推文的用户的数组.
No one seems to be able to answer my question and I can not find it in the other posts. Using twitter's api, I want to enter in a tweet id and return an array of all the users who retweeted that tweet.
示例:
input -> retweeters(tweet_id)
output -> ['username1','username2','username3','username4']
这可以通过这个链接
我不需要推文或转推,我需要转推特定推文的人的用户名,因此 retweets_of_me 在这里没有帮助.如果你帮助我,我将不胜感激.谢谢
I do not need the tweet or the retweet, I need the usernames of the people who retweeted a particular tweet so therefore retweets_of_me would not be helpful here. If you help me out, I'd be very grateful. Thank you
推荐答案
您可以使用 twython,允许您使用以下代码访问 Twitter API 并收集转发者 ID 列表:
You can use twython, which allows you to access the Twitter API and collect the list of retweeter IDs with the following code:
from twython import Twython
twitter = Twython(APP_KEY, APP_SECRET,OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
search = twitter.get_retweeters_ids(id=327473909412814850)
for result in search["ids"]:
print result
get_retweeters_ids()
函数采用与 Twitter API 调用相同的参数,即您要跟踪的推文的 ID.结果是一个 JSON 对象,其中包含字段ids"中的转发者 ID.
The get_retweeters_ids()
function takes the same arguments as the Twitter API call, which is the id of the Tweet you want to track. The result is a JSON object that contains the retweeter IDs in the field "ids".
我希望这会有所帮助.
这篇关于在python中使用twitter api命令实现的困难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!