how to get the JSON object through URL in my ruby on rails code:
url = "https://graph.facebook.com/me/friends?access_token=XXX"
I am not able to get good tutorial for JSON + Ruby on rails. Can someon开发者_JAVA技巧e help me out thanks.
require 'open-uri'
require 'json'
json_object = JSON.parse(open("https://graph.facebook.com/me/friends?access_token=XXX").read)
This is the simplest way, though it may not be the fastest.
Edit: If the URI contains special characters in its parameter string, it has to be escaped/encoded with URI.escape
first.
精彩评论