0

I'm building a Facebook canvas app in Rails, and I'm looking to display all of the photos in a given photo album. I can generate the URL that will take me to a page with a JSON feed of the data associated with those photos, but I'm not clear on how to capture that information and store it in an array within Rails. If anyone could help me I'd appreciate it!

The request I'm making is to:

https://graph.facebook.com/'+album["id"].to_s+'/photos/?fields=source&access_token='+@token["oauth_token"]

Where album['id'] and @token[oauth_token] are user specific.

sowasred2012
  • 695
  • 1
  • 7
  • 22
  • Usually you capture the data into a model you've created. Is there something exotic here you're not describing? – tadman Oct 15 '12 at 15:50
  • Nothing exotic - all I'm doing is grabbing the cover images of each of the user's albums with the intention that, when the user clicks the image, they'd be taken to another page with all of the images from that album present. I just don't have a lot of experience with JSON, especially not within Rails. – sowasred2012 Oct 15 '12 at 15:56
  • http://stackoverflow.com/questions/1826727/how-do-i-parse-json-with-ruby-on-rails – jdl Oct 15 '12 at 16:25
  • Could you please update how your request will be so that I can write the logic to parse the JSON and store data into the database? – Soundar Rathinasamy Oct 15 '12 at 16:43
  • @soundar I've just updated, is that what you need? – sowasred2012 Oct 15 '12 at 17:01
  • @sowasred2012 shall we continue this in chat? – Soundar Rathinasamy Oct 15 '12 at 17:24

1 Answers1

1

If you have a JSON string var_json_string, you can convert it to a Hash by doing:

JSON.parse(var_json_string)
TTT
  • 6,505
  • 10
  • 56
  • 82
  • Cheers, the problem I was having was with using the net/http gem, I couldn't catch the response from that address, but I've found HTTParty, and that solved my first issue. Your answer then helped with the rest! – sowasred2012 Oct 16 '12 at 09:41