-
-
Save ch1ago/8737184 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# not necessary in Rails | |
require 'cgi' | |
require 'openssl' | |
require 'open-uri' | |
# OPTIONS :force, :full_page, :thumb_width, :width, :height | |
def urlbox(url, options={}) | |
urlbox_apikey = 'xxx-xxx' | |
urlbox_secret = 'xxx-xxx' | |
options.merge!(url: url) | |
query_string = options.select { |k,v| v }.to_query | |
# puts query_string | |
puts URI::encode(query_string) | |
token = OpenSSL::HMAC.hexdigest('sha1', urlbox_secret, query_string) | |
"https://api.urlbox.io/v1/#{urlbox_apikey}/#{token}/png?#{query_string}" | |
end | |
puts urlbox "www.google.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment