Class: StreamBot::OAuth
Overview
oauth communication wrapper
Constant Summary collapse
- TWITTER_OAUTH_SPEC =
{ :site => 'http://api.twitter.com', :request_token_pat1h => '/oauth/request_token', :access_token_path => '/oauth/access_token', :authorize_path => '/oauth/authorize' }
- ACCESS_TOKEN =
'access_token.yml'
Instance Method Summary collapse
-
#get(path) ⇒ Object
get data from twitter api.
-
#initialize(auth) ⇒ OAuth
constructor
:nodoc:.
-
#post(path, body) ⇒ Object
post data to twitter api.
Methods inherited from Handler
Constructor Details
#initialize(auth) ⇒ OAuth
:nodoc:
14 15 16 17 18 |
# File 'lib/streambot/oauth.rb', line 14 def initialize(auth) @auth = auth @oauth_consumer = ::OAuth::Consumer.new(@auth['key'], @auth['secret'], TWITTER_OAUTH_SPEC) get_access_token end |
Instance Method Details
#get(path) ⇒ Object
get data from twitter api
path takes the path like
'/statuses/user_timeline.format'
39 40 41 42 43 |
# File 'lib/streambot/oauth.rb', line 39 def get(path) LOG.debug("get data form \"#{path}\"") response = @access_token.get(path) parse_response(response) end |
#post(path, body) ⇒ Object
post data to twitter api
url takes the path like
'/statuses/update.format'
the body contains all data you send to twitter
{:status => "a new status"}
28 29 30 31 32 |
# File 'lib/streambot/oauth.rb', line 28 def post(path, body) LOG.debug("post #{body} to \"#{path}\"") response = @access_token.post(path, body) parse_response(response) end |