开发者

Get a json object from the url while using facebook graph api in ruby on rails

开发者 https://www.devze.com 2023-03-23 21:31 出处:网络
how to get the JSON object through URL in my ruby on rails code: url = \"https://graph.facebook.com/me/friends?access_token=XXX\"

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消