Created
December 11, 2011 19:41
-
-
Save kirs/1462329 to your computer and use it in GitHub Desktop.
Google Translation API: Ruby example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'google/api_client' | |
client = Google::APIClient.new | |
translate = client.discovered_api('translate', 'v2') | |
client.authorization.access_token = '123' # dummy | |
client.key = "my-key-example" # your key from Google API console | |
response = client.execute( | |
:api_method => translate.translations.list, | |
:parameters => { | |
'format' => 'text', | |
'source' => 'en', | |
'target' => 'es', | |
'q' => 'The quick brown fox jumped over the lazy dog.' | |
} | |
) | |
status, headers, body = response | |
puts response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment