Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 868
Anurag Avatar asked Jul 31 '11 07:07

Anurag


1 Answers

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.

like image 198
M. Cypher Avatar answered Sep 27 '22 06:09

M. Cypher