0

I have been trying for two days to figure this out and can't get what I am doing wrong. I have been working with APIs for a while now, but this is the first time I have tried it with Ruby.

Currently this what I have:

require 'httparty'    

response = URI.parse('http://api.remix.bestbuy.com/v1/stores(area(55423,20))?apiKey=xxxxxxxxxxxxxx')
parse = CGI.parse(response.query)

result = parse['id'].first  

$result = result 

I plan to move $result to result.html.erb to iterate into a table, but not sure if I have the parsing done correctly, since I can't view the contents of reponse or $result. Any idea if I am even close? and how to iterate through the xml after..

5
  • Shouldn't you look at response.body instead of response.query? Commented Nov 13, 2014 at 7:12
  • For parsing you can use nokogiri.org Commented Nov 13, 2014 at 7:13
  • I have been trying to figure out Nokogiri as well. Sometimes it isn't such a great thing when you have so many options, as in Nokogiri. Just want to pull the XML data, parse it into a useable array that I can iterate into an html table. Commented Nov 13, 2014 at 7:32
  • It is not supposed to be that difficult: doc = Nokogiri::HTML(open("http://www.threescompany.com/")) Commented Nov 13, 2014 at 7:35
  • I was more focused on the problem, than a key. I made it more 'anon' thanks. I'll give that a shot with Noko. Commented Nov 13, 2014 at 7:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.