Class: TwiAuth::OAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/twiauth/oauth.rb

Overview

oauth communication wrapper

Constant Summary collapse

TWITTER_OAUTH_SPEC =
{
        :site => 'https://api.twitter.com',
        :request_token_path => '/oauth/request_token',
        :access_token_path => '/oauth/access_token',
        :authorize_path => '/oauth/authorize'
}
ACCESS_TOKEN =

key for access token

'ACCESS_TOKEN'

Instance Method Summary collapse

Constructor Details

#initialize(key, secret) ⇒ OAuth

Returns a new instance of OAuth.



15
16
17
18
19
# File 'lib/twiauth/oauth.rb', line 15

def initialize(key, secret)
  @store = TwiAuth::Store.new
  @oauth_consumer = ::OAuth::Consumer.new(key, secret, TWITTER_OAUTH_SPEC)
  get_access_token
end

Instance Method Details

#drop_access_tokenObject



29
30
31
# File 'lib/twiauth/oauth.rb', line 29

def drop_access_token
  @store.delete(ACCESS_TOKEN)
end

#get(path) ⇒ Object



21
22
23
# File 'lib/twiauth/oauth.rb', line 21

def get(path)
  @access_token.get(path)
end

#post(path, body = nil) ⇒ Object



25
26
27
# File 'lib/twiauth/oauth.rb', line 25

def post(path, body = nil)
  @access_token.post(path, body)
end