Google APIs examples-api-ruby-client

I was very happy to see the google code: google-api-ruby-client , because it meant for me that Ruby users could polish the code using the Google -s API .

At the moment, although I'm downplaying it because the above example uses Buzz and from my experiments, the Google Translate (v2) api should behave differently with Buzz in the google-api-ruby-client .

I was intrigued by the demo Explorer. But, as I understand it, this is not much of a researcher. All he does is call the Buzz service, and then think about things that ALREADY know about Buzz services. For me, a researcher should let you β€œdiscover” services and methods / functions that can be discovered without even knowing them.

I would like to hear about the Ruby command line and desktop applications using this: google-api-ruby-client for services other than Buzz and, in particular, Translate api (I'm less interested in existing Ruby stones using the translation service at this stage) .

thanks ... will

+5
source share
5 answers

The code to call the translation API is as follows:

require 'google/api_client'
client = Google::APIClient.new(:key => YOUR_DEVELOPER_KEY)
translate = client.discovered_api('translate', 'v2')
result = client.execute(
  :api_method => translate.translations.list,
  :parameters => {
    'format' => 'text',
    'source' => 'en',
    'target' => 'es',
    'q' => 'The quick brown fox jumped over the lazy dog.'
  }
)
+9
source

I posted the full code and detailed information about the problems and workarounds (using the api key) in the abode code - google-api-client for ruby

After installing the gem, getting the Google API key and setting up a user search account (with its prefixes extended for all web pages) .... I could trawl Google search results in irb with the following (copy paste to irb and then check answer when done):

  require 'openssl'
  OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

  require 'google/api_client'
  client = Google::APIClient.new(:key => 'your-api-key', :authorization => nil)
  search = client.discovered_api('customsearch')

  response = client.execute(
    :api_method => search.cse.list,
    :parameters => {
      'q' => 'the hoff',
      'key' => 'your-api-key',
      'cx' => 'your-custom-search-id'
    }
  )

google api oauth. : ... , api , oauth. 401.

+3

, .

.CRT. CA-, CA-, cURL (http://curl.haxx.se/ca).

: NetHhttps HTTPS

, OpenSSL.

.

0

() ,

. Google-API-Ruby-client . , Translate ( ) Google-API-Ruby-client SSL:: VERIFY_PEER SSL:: VERIFY_NONE.

.

  • API- , ( ) , .
  • (, SSL? VERIFY_PEER VERIFY_NONE? URI, ? , "Requested" ( ) .
  • Gem (, , : , ​​).
0

I have a solution here (http://jjinux.blogspot.com/2012/02/ruby-working-around-ssl-errors-on-os-x.html) that the monkey fixes Net :: HTTP # use_ssl = for Using root operating system certificates.

0
source

All Articles