LoginSignup
15
15

More than 5 years have passed since last update.

RubyでUser Streamsを使ってhome timelineを取得

Last updated at Posted at 2013-01-20

今更ですが、ユーザーストリームでホームタイムラインを取得したくなったので投稿します。


今回は、tweetstreamを使用しました。以下のコマンドでインストールしておいてください。

gem install tweetstream

以下コードです。非常にシンプルですね。記事にするまでのなかったかもしれません。

require 'tweetstream'

TweetStream.configure do |config|
  config.consumer_key       = '********'
  config.consumer_secret    = '********'
  config.oauth_token        = '********'
  config.oauth_token_secret = '********'
  config.auth_method        = :oauth
end

client = TweetStream::Client.new
client.userstream do |status|
  puts "#{status.user.name}: #{status.text}"
end

タイムラインにツイートが加わるとそのツイートを表示してくれちゃいます。

15
15
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15