Created
June 16, 2016 11:29
-
-
Save bodrovis/62a81cc8bd6466e56a8b5a6ae68328b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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