Skip to content

Instantly share code, notes, and snippets.

@bodrovis
Created June 16, 2016 11:29
Show Gist options
  • Save bodrovis/62a81cc8bd6466e56a8b5a6ae68328b5 to your computer and use it in GitHub Desktop.
Save bodrovis/62a81cc8bd6466e56a8b5a6ae68328b5 to your computer and use it in GitHub Desktop.
# A (very) naive approach to load arbitrary number of tweets
# using max_id option
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ''
config.consumer_secret = ''
config.access_token = ''
config.access_token_secret = ''
end
tweets = []
options = {count: 10, include_rts: true} # count <= 200
loop do
options[:max_id] = (tweets.last.id - 1) if tweets.any? # just get the latest tweet's id
tweets.push(*client.user_timeline('USERNAME_HERE', options))
break if tweets.count > 50 # any number...
end
puts tweets.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment