Class: MultiShorten::GooGl

Inherits:
UrlShortener show all
Defined in:
lib/multi_shorten/url_shorteners.rb

Overview

URL Shortener for goo.gl

Class Method Summary collapse

Methods inherited from UrlShortener

#fail

Class Method Details

.shorten(url) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/multi_shorten/url_shorteners.rb', line 61

def self.shorten url
  response = post "/v1/url", :headers => {"Content-Type" => "application/json"}, :body => JSON.dump({:longUrl => URI.encode(url)})
  unless response.parsed_response["id"].nil?
    { :status => :success, :short_url => response.parsed_response["id"] }
  else
    fail
  end
end