Class: Twitorious::Auth::OAuth

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

Instance Method Summary collapse

Constructor Details

#initializeOAuth

Returns a new instance of OAuth.



7
8
9
10
11
12
# File 'lib/twitorious/auth/oauth.rb', line 7

def initialize
  @consumer = ::OAuth::Consumer.new( 
    "oZglZozO6F3p1Ed8n9F6fw", 
    "onR6S9HS54D40Qg1KfI16c9A72KRoJKJwaXe73Tv0",
    { :site => "http://twitter.com" })
end

Instance Method Details

#authorize_urlObject



19
20
21
# File 'lib/twitorious/auth/oauth.rb', line 19

def authorize_url
  @request_token.authorize_url
end

#get(url, path) ⇒ Object



33
34
35
36
# File 'lib/twitorious/auth/oauth.rb', line 33

def get(url, path)
  res = @access_token.get path
  return res.body 
end

#get_access_tokenObject



28
29
30
31
# File 'lib/twitorious/auth/oauth.rb', line 28

def get_access_token
  @access_token ||= ::OAuth::AccessToken.new(@consumer, @token, @secret)
  @access_token
end

#get_request_tokenObject



14
15
16
17
# File 'lib/twitorious/auth/oauth.rb', line 14

def get_request_token
  @request_token = @consumer.get_request_token
  @request_token
end

#post(url, path, form_data) ⇒ Object



38
39
40
41
# File 'lib/twitorious/auth/oauth.rb', line 38

def post(url, path, form_data)
  res = @access_token.post path, form_data
  return res.body
end

#set_token(token, secret) ⇒ Object



23
24
25
26
# File 'lib/twitorious/auth/oauth.rb', line 23

def set_token(token, secret)
  @token, @secret = token, secret
  get_access_token
end