Get json object from url when using facebook api chart in ruby ​​on rails

how to get json object via url in my ruby ​​on rails code:

url = "https://graph.facebook.com/me/friends?access_token=XXX" 

I cannot get a good tutorial for JSON + Ruby on rails. Can someone help me thanks.

+8
json ruby ruby-on-rails
source share
1 answer
 require 'open-uri' require 'json' json_object = JSON.parse(open("https://graph.facebook.com/me/friends?access_token=XXX").read) 

This is the easiest way, although it may not be the fastest.

Edit: if a URI contains special characters in its parameter string, it must first be escaped / encoded using URI.escape .

+27
source share

All Articles