Class: Orkut::Connect

Inherits:
Object
  • Object
show all
Defined in:
lib/orkut/connect/connect.rb,
lib/orkut/connect/request.rb

Defined Under Namespace

Modules: Request

Instance Method Summary collapse

Instance Method Details

#initialize_consumer(client = nil) ⇒ Object

generic consumer initializer



8
9
10
11
12
13
14
15
# File 'lib/orkut/connect/connect.rb', line 8

def initialize_consumer(client=nil)
  
  OAuth::Consumer.new( client.consumer_key, client.consumer_secret,
                        :site               => "https://www.google.com",
                        :request_token_path => "/accounts/OAuthGetRequestToken",
                        :access_token_path  => "/accounts/OAuthGetAccessToken",
                        :authorize_path     => "/accounts/OAuthAuthorizeToken")
end

#post_json_rpc(client, subject) ⇒ Object

generic post json rpc call



18
19
20
21
22
23
24
25
26
27
# File 'lib/orkut/connect/connect.rb', line 18

def post_json_rpc(client, subject)
    consumer = initialize_consumer client
    token_hash = { :oauth_token => client.oauth_token, :oauth_token_secret => client.oauth_token_secret }
    access_token = OAuth::AccessToken.from_hash consumer, token_hash 
  
    data = access_token.post(Orkut::Config::DEFAULT_RPC_ENDPOINT, subject, 
                      { "Content-Type" => "application/json" }).body                        
                      
    MultiJson.decode data 
end