Revisions
-
ch1ago revised this gist
Jan 31, 2014 . 1 changed file with 5 additions and 15 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,15 @@ # 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 -
urlbox-io revised this gist
Feb 21, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def urlbox(url, options={}) 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" -
urlbox-io revised this gist
Feb 17, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def urlbox(url, options={}) 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" -
urlbox-io created this gist
Feb 17, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ require 'cgi' require 'openssl' require 'open-uri' def urlbox(url, options={}) urlbox_apikey = 'xxx-xxx' urlbox_secret = 'xxx-xxx' query = { :url => url, :force => options[:force], :full_page => options[:full_page], :thumb_width => options[:thumb_width], :width => options[:width], :height => options[:height], } query_string = query. sort_by {|s| s[0].to_s }. select {|s| s[1] }. map {|s| s.map {|v| CGI::escape(v.to_s) }.join('=') }. join('&') # puts query_string puts URI::encode(query_string) token = OpenSSL::HMAC.hexdigest('sha1', urlbox_secret, query_string) "http://api.urlbox.io/v1/#{urlbox_apikey}/#{token}/png/?#{query_string}" end puts urlbox "www.google.com"