Updated example.

git-svn-id: https://google-api-ruby-client.googlecode.com/svn/trunk@44 c1d61fac-ed7f-fcc1-18f7-ff78120a04ef
This commit is contained in:
Bob Aman 2010-10-07 22:12:27 +00:00
parent e26ebaf981
commit de394a55c6
2 changed files with 30 additions and 3 deletions

25
README
View File

@ -13,18 +13,37 @@ APIs.
== Example Usage
require 'google/api_client'
client = Google::APIClient.new(:service => 'buzz')
require 'signet/oauth_1/client'
client = Google::APIClient.new(
:service => 'buzz',
:authorization => Signet::OAuth1::Client.new(
:temporary_credential_uri =>
'https://www.google.com/accounts/OAuthGetRequestToken',
:authorization_uri =>
'https://www.google.com/buzz/api/auth/OAuthAuthorizeToken',
:token_credential_uri =>
'https://www.google.com/accounts/OAuthGetAccessToken',
:client_credential_key => 'anonymous',
:client_credential_secret => 'anonymous'
)
)
client.authorization.fetch_temporary_credential!(
:additional_parameters => {
'scope' => 'https://www.googleapis.com/auth/buzz'
}
)
client.authorization.authorization_uri
client.authorization.authorization_uri(
:additional_parameters => {
'domain' => client.authorization.client_credential_key,
'scope' => 'https://www.googleapis.com/auth/buzz'
}
)
# Redirect user here
client.authorization.fetch_token_credential!(:verifier => '12345')
response = client.execute(
'buzz.activities.list',
'scope' => '@self', 'userId' => '@me', 'alt' => 'json'
{'scope' => '@self', 'userId' => '@me', 'alt' => 'json'},
'', [], {:signed => true}
)
status, headers, body = response

View File

@ -298,6 +298,14 @@ module Google
# otherwise. Defaults to <code>true</code>.
#
# @return [Array] The response from the API.
#
# @example
# response = client.execute(
# 'chili.activities.list',
# {'scope' => '@self', 'userId' => '@me', 'alt' => 'json'},
# '', [], {:signed => true}
# )
# status, headers, body = response
def execute(api_method, parameters={}, body='', headers=[], options={})
request = self.generate_request(
api_method, parameters, body, headers, options