Skip to content

Instantly share code, notes, and snippets.

@xenji
Created June 11, 2012 18:23
Show Gist options
  • Save xenji/2911750 to your computer and use it in GitHub Desktop.
Save xenji/2911750 to your computer and use it in GitHub Desktop.
entries = Atom::Feed.load_feed(URI.parse("https://speakerdeck.com/u/xenji.atom"))
base_url = "https://speakerdeck.com"
path = "/oembed.json?url="
@embeds = []
entries.each_entry do |entry|
link = entry.links.alternate.to_s.sub "https", "http"
fullpath = path + CGI.escape(link)
uri = URI.parse(base_url + fullpath)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
json = response.body
@embeds.push ActiveSupport::JSON.decode(json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment