[英]ruby/rails ruby/rails How can I get all the tweets from Twitter LIST (of users) using the Twitter API?
I would like using the twitter API get all the tweets from a twitter list (of users). 我想使用twitter API从(用户)twitter列表中获取所有tweet。
I would like to have a JSON response with the all the tweets in the list. 我想使用列表中的所有tweet进行JSON响应。 Will parse the JSON to look for hashtags and create graphs.
将解析JSON以查找主题标签并创建图。 I would like to use ruby/rails doing it.
我想用ruby / rails做到这一点。 I were not able to find in the twitter API a way to search list.
我无法在twitter API中找到搜索列表的方法。 Any insight is appreciated.
任何见解均表示赞赏。
This is what I end up doing. 这就是我最终要做的。 In the model i added the function:
在模型中,我添加了功能:
def self.list_latest()
list = URI.parse('https://twitter.com/USERNAME/LISTNAME')
$client.list_timeline(list).each do |tweet|
unless exists?(tweet_id: tweet.id)
create!(
tweet_id: tweet.id,
content: tweet.text,
screen_name: tweet.user.screen_name,
)
end
end
end
I get the tweets from my list and add them to my DB if the tweet ID does not exist. 我从列表中获取了tweet,如果tweet ID不存在,则将它们添加到我的数据库中。
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.