title: How do you iterate over and retrieve values from a hash with arrays?
body: <p>I am trying to build a quick hack that "likes" all the recent photos on instagram of a particular tag. </p>
  
  <p>I have authenticated and used the JSON gem to turn the JSON from the API into a Ruby Hash like this: </p>
  
  <pre><code>def get_content (tag_name)
  
     uri = URI.parse("https://api.instagram.com/v1/tags/#{tag_name}/media/recent? access_token=#{@api_token}")
  
     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)
  
     json_output = http.request(request)
     @tags = JSON.parse(json_output.body)
  
  end
  </code></pre>
  
  <p>This outputs a hash with arrays as keys nested like the original JSON ( ex. <code>http://instagr.am/developer/endpoints/tags/</code>)</p>
  
  <p>I am trying to iterate over and retrieve all the "id"s of the photos.</p>
  
  <p>However when I use each method: </p>
  
  <pre><code>@tags.each do |item| 
    puts item["id"]
  end
  </code></pre>
  
  <p>I get an error:</p>
  
  <pre><code>instagram.rb:23:in `[]': can't convert String into Integer (TypeError)
  from instagram.rb:23:in `block in like_content'
  from instagram.rb:22:in `each'
  from instagram.rb:22:in `like_content'
  from instagram.rb:42:in `&lt;main&gt;'
  </code></pre>