3 ms·
I use Embed.ly for a side-project site I hacked together quickly (www.senioritis.com) and I love it. The beauty of Embed.ly is that users can submit a link, my
by ai09 16y ago
I use Embed.ly for a side-project site I hacked together quickly (www.senioritis.com) and I love it.
The beauty of Embed.ly is that users can submit a link, my site calls out to Embed.ly, and Embed.ly returns HTML for embedding in the page. In my quick hack I don't even check whether Embed.ly can handle the link, etc. but just embed the HTML if the response isn't nil (though I understand the XSS risks and need to fix it).
Parse the JSON response of:
Net::HTTP.get(URI.parse("http://api.embed.ly/v1/api/oembed?url=#{self.web_link}) http://api.embed.ly/v1/api/oembed?url=#{self.web_link}))
and you're set. I love how simple it is.
One thing re Embed.ly, their server sometimes takes some time to respond and so I recommend using DelayedJob. Right now my horrible hack just uses an after_create hook in rails to call the Embed.ly server in the same thread but sometimes that times out or has a noticeable delay.