tags:

views:

41

answers:

1

i want use oohembed for get informations of some links.

How can i retreive json data from a link:

http://oohembed.com/oohembed/?url=http://www.youtube.com/watch?v=iWhmOPJXpSw&feature=subtivity

like

{ "title": "Aquarium", "html": "", "author_name": "passmorelab", "height": 344, "thumbnail_width": 120, "width": 425, "version": "1.0", "author_url": "http://www.youtube.com/user/passmorelab", "provider_name": "Youtube", "thumbnail_url": "http://i.ytimg.com/vi/iWhmOPJXpSw/1.jpg", "type": "video", "thumbnail_height": 90 }

and import it in a variable?

thanks

A: 

The fastest way

require "json"
var= JSON.load(`wget -O - "url"`)

This is good for a throw away script. But not for anything real.

The nice way

require "json"
require "net/http"
require "uri"

JSON.load(Net::HTTP.get(URI.parse(url)))
johannes