Class: GoogleApi

Inherits:
GenericApi show all
Includes:
HTTParty
Defined in:
lib/apis/google_api.rb

Instance Method Summary collapse

Methods inherited from GenericApi

#initialized?

Instance Method Details

#key=(key) ⇒ Object

Simply declare and remember the API Key


39
40
41
42
# File 'lib/apis/google_api.rb', line 39

def key=(key)
  @api_key = key
  GoogleApi.default_params(:key => key, :v => '1.0')
end

#lookup_feed_url(page_url) ⇒ Object


44
45
46
47
48
49
50
51
52
53
# File 'lib/apis/google_api.rb', line 44

def lookup_feed_url(page_url)
  begin
    result = GoogleApi.get("/feed/lookup", :query => {:q => page_url})
  rescue Net::HTTPServerException => exception
    puts "\nEXCEPTION: from GoogleApi::lookup_feed_url: #{exception.response.body}"
    return nil
  end
  resp = result["responseData"]
  resp.nil? ? nil : resp["url"]
end