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 someone 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.