here is one simple way to generate using http://tinyurl.com/ service, easy of use :)
require 'open-uri'
require 'uri'
retrun_URL = 'http://chart.apis.google.com/chart?chxl=0:|load+google+landing+page|click_suggestion|1:|0|1|2|3|4|5&chxt=x,y&chco=76A4FB&chd=s:94&chtt=Detail+Page+Response+Time+for+GoogleSuggest.html&cht=lc&chs=900x300&chxr=1,5.977,5.401'
encoding_url = URI.escape(retrun_URL, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
tiny_url = open("http://tinyurl.com/api-create.php?url=#{encoding_url}").read
puts tiny_url
Sample OUTPUT:
>>http://tinyurl.com/1c2
Note: If you did not encoding/escape the URL, then the service will call it "bad URI(is not URI?)...URI::InvalidURIError"
No comments:
Post a Comment