¶ ↑
This forkAdds stats querying and optional full response hashes for all queries.
¶ ↑
GoShortenerUses Google URL shortener API service to shorten/expand given URLs.
¶ ↑
Usage¶ ↑
Installationgem install goshortener
of if you are using bundler in your project, add the following line to your Gemfile.
gem "goshortener"
¶ ↑
Initializego = GoShortener.new(YOUR_API_KEY)
or
go = GoShortener.new
Using Google API keys will increase the usage quota.
¶ ↑
Shorten urlsshort_url = go.shorten "http://github.com/luckydev"
¶ ↑
To expand short urlslong_url = go.lengthen short_url
¶ ↑
Example usage in irbruby-1.9.2-p136 :001 > require "goshortener" => true ruby-1.9.2-p136 :002 > go = GoShortener.new("yourapikeyfromgoogle") => #<GoShortener:0x93b35e0 @base_url="https://www.googleapis.com/urlshortener/v1/url", @api_key="yourapikeyfromgoogle"> ruby-1.9.2-p136 :003 > go.shorten "http://github.com/luckydev" => "http://goo.gl/TCZHi" ruby-1.9.2-p136 :004 > go.lengthen "http://goo.gl/TCZHi" => "http://github.com/luckydev"
¶ ↑
Usage in Rails projectIf you are using goshortener in a rails project, you can put the following lines in an initializer file. For example, in config/initializers/goshortener.rb
GO = GoShortener.new(YOUR_API_KEY)
And anywhere in your rails project, you can call GO.shorten or GO.lengthen
¶ ↑
Authorlakshmanan (lucky.developer@gmail.com)