require 'twitter' client = Twitter::REST::Client.new do |config| config.consumer_key = "YOUR_CONSUMER_KEY" config.consumer_secret = "YOUR_CONSUMER_SECRET" config.access_token = "YOUR_ACCESS_TOKEN" config.access_token_secret = "YOUR_ACCESS_SECRET" end user = client.user("23Cent") puts user.name def collect_with_max_id(collection=[], max_id=nil, &block) response = yield(max_id) collection += response response.empty? ? collection.flatten : collect_with_max_id(collection, response.last.id - 1, &block) end def client.get_all_tweets(user) collect_with_max_id do |max_id| options = {count: 200, include_rts: true} options[:max_id] = max_id unless max_id.nil? user_timeline(user, options) end end tweets = client.get_all_tweets("23Cent") tweets.each do |t| puts t.id, t.uri, t.created_at puts t.full_text end