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:
parent
e26ebaf981
commit
de394a55c6
25
README
25
README
|
@ -13,18 +13,37 @@ APIs.
|
||||||
== Example Usage
|
== Example Usage
|
||||||
|
|
||||||
require 'google/api_client'
|
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!(
|
client.authorization.fetch_temporary_credential!(
|
||||||
:additional_parameters => {
|
:additional_parameters => {
|
||||||
'scope' => 'https://www.googleapis.com/auth/buzz'
|
'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
|
# Redirect user here
|
||||||
client.authorization.fetch_token_credential!(:verifier => '12345')
|
client.authorization.fetch_token_credential!(:verifier => '12345')
|
||||||
response = client.execute(
|
response = client.execute(
|
||||||
'buzz.activities.list',
|
'buzz.activities.list',
|
||||||
'scope' => '@self', 'userId' => '@me', 'alt' => 'json'
|
{'scope' => '@self', 'userId' => '@me', 'alt' => 'json'},
|
||||||
|
'', [], {:signed => true}
|
||||||
)
|
)
|
||||||
status, headers, body = response
|
status, headers, body = response
|
||||||
|
|
||||||
|
|
|
@ -298,6 +298,14 @@ module Google
|
||||||
# otherwise. Defaults to <code>true</code>.
|
# otherwise. Defaults to <code>true</code>.
|
||||||
#
|
#
|
||||||
# @return [Array] The response from the API.
|
# @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={})
|
def execute(api_method, parameters={}, body='', headers=[], options={})
|
||||||
request = self.generate_request(
|
request = self.generate_request(
|
||||||
api_method, parameters, body, headers, options
|
api_method, parameters, body, headers, options
|
||||||
|
|
Loading…
Reference in New Issue