Last Updated: February 25, 2016
·
918
· vjt

Fetch the latest pictures posted by a twitter user

$ gem install twitter rest-client

$ irb (or pry, that's even better :-)

require 'twitter'
require 'restclient'

t = Twitter::Client.new(:consumer_key => 'YOUR_APP_KEY', :consumer_secret => 'YOUR_APP_SECRET', :oauth_token => 'YOUR_AUTH_TOKEN', :oauth_token_secret => 'YOUR_AUTH_SECRET')

photos = t.user_timeline(:screen_name => 'amedeo').map {|t| t.media.map(&:media_url) if t.media.size > 0}.compact.flatten

photos.each {|uri| print "Fetching #{uri}:large ..."; File.open(File.basename(uri), 'w+') { |f| f.write RestClient.get([uri, 'large'].join(':')) }; puts 'done' }

Find your .jpg in the current working directory. :-)