简体   繁体   English

ruby / rails ruby​​ / rails如何使用Twitter API从(用户的)Twitter LIST获取所有推文?

[英]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.

相关问题 Twitter和最近的推文Ruby on Rails - Twitter and Recent Tweets Ruby on Rails 如何使用 Ruby on Rails 模拟 twitter api? - How to mock to twitter api using Ruby on Rails? Ruby on Rails:如何使用Twitter搜索Api从next_page获取推文? 什么应该是我的since_id和max_id? - Ruby on Rails: How to get tweets from the next_page using the Twitter search Api? And What should be my since_id and max_id? 在Rails应用程序中使用Twitter API显示选定的用户推文 - Display a chosen users tweets using twitter api in a rails app 从Ruby on Rails的Twitter获得喜欢 - Get likes from twitter in Ruby on rails 如何在Ruby On Rails中将Twitter API Pull转换为数组? - How do I convert a Twitter API Pull into an Array in Ruby On Rails? 我正在Ruby On Rails中创建一个Twitter克隆,我如何编码它以便'推文'中的'@ ...'变成链接? - I am creating a Twitter clone in Ruby On Rails, how do I code it so that the '@…''s in the 'tweets' turn into links? 如何使用访问令牌在Twitter或Facebook上的ruby上的GET和POST上发布 - how to GET and POST on Twitter or facebook in ruby on rails using access tokens 如何在Ruby on Rails中使用datasift在twitter-vibe中显示实时推文 - How to display live tweets in twitter-vibe using datasift in Ruby on Rails Ruby on Rails中的Twitter引导程序 - Twitter Bootstrap in Ruby on Rails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM