Skip to content

Instantly share code, notes, and snippets.

@hayduke19us
Created April 25, 2014 21:59
Show Gist options
  • Save hayduke19us/11304705 to your computer and use it in GitHub Desktop.
Save hayduke19us/11304705 to your computer and use it in GitHub Desktop.
require 'net/https'
require 'uri'
require 'json'
API_KEY = '59a3d0192d16da2a2d739d0c9d25fdf4'
CITY = 'seattle'
uri = URI.parse("https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=#{API_KEY}&tags=#{CITY}&safe_search=1&per_page=10&page=1&format=json&nojsoncallback=1")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response = JSON.parse(response.body)
photos = response["photos"]
puts photos['photo']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment