Skip to content

Instantly share code, notes, and snippets.

@phudgins
Created December 7, 2011 19:45
Show Gist options
  • Save phudgins/1444302 to your computer and use it in GitHub Desktop.
Save phudgins/1444302 to your computer and use it in GitHub Desktop.
meme capt api call
require 'typhoeus'
require 'yajl/json_gem'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object'
hydra = Typhoeus::Hydra.new
params = { u: "http://memecaptain.com/all_the_things.jpg",
tt: "All the things",
tb: "use memecaptain api!" }.to_param
request = Typhoeus::Request.new("http://memecaptain.com/g?#{params}",
{ method: :get,
timeout: 10000,
headers: {:Accept => "application/json",
"Content-Type" => "application/json"} })
request.on_complete do |response|
@parsed = Yajl::Parser.parse(response.body, symbolize_keys: true)
end
hydra.queue(request)
hydra.run
puts @parsed[:permUrl]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment