Class: TwitterRequestHeaders
- Inherits:
-
Object
- Object
- TwitterRequestHeaders
- Defined in:
- lib/twitter_request_headers.rb
Constant Summary collapse
- OAUTH_VERSION =
'1.0'
- OAUTH_CIPHER =
'HMAC-SHA1'
- TWITTER_API =
'https://api.twitter.com/1.1'
Class Attribute Summary collapse
-
.consumer_key ⇒ Object
readonly
Returns the value of attribute consumer_key.
-
.consumer_secret ⇒ Object
readonly
Returns the value of attribute consumer_secret.
-
.oauth_cipher ⇒ Object
readonly
Returns the value of attribute oauth_cipher.
-
.oauth_version ⇒ Object
readonly
Returns the value of attribute oauth_version.
-
.twitter_api ⇒ Object
readonly
Returns the value of attribute twitter_api.
Class Method Summary collapse
-
.configure(consumer_key, consumer_secret, oauth_version = nil, oauth_cipher = nil, twitter_api = nil) ⇒ true
Define Twitter application credentials and options to be accessible from rest of all library.
Instance Method Summary collapse
-
#header ⇒ Hash
HTTP header of format: => ‘OAuth …’.
-
#initialize(oauth_token, oauth_secret, request_verb, request_path, request_params = nil) ⇒ TwitterRequestHeaders
constructor
Creates new session.
Constructor Details
#initialize(oauth_token, oauth_secret, request_verb, request_path, request_params = nil) ⇒ TwitterRequestHeaders
Creates new session.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/twitter_request_headers.rb', line 42 def initialize(oauth_token, oauth_secret, request_verb, request_path, request_params = nil) unless @@configured fail StandardError, "Call #{self.class}.configure first!" end @oauth_token = oauth_token @oauth_secret = oauth_secret @request_verb = request_verb @request_path = request_path @request_params = request_params || {} @nonce = nonce @epochtime = epochtime end |
Class Attribute Details
.consumer_key ⇒ Object (readonly)
Returns the value of attribute consumer_key.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def consumer_key @consumer_key end |
.consumer_secret ⇒ Object (readonly)
Returns the value of attribute consumer_secret.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def consumer_secret @consumer_secret end |
.oauth_cipher ⇒ Object (readonly)
Returns the value of attribute oauth_cipher.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def oauth_cipher @oauth_cipher end |
.oauth_version ⇒ Object (readonly)
Returns the value of attribute oauth_version.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def oauth_version @oauth_version end |
.twitter_api ⇒ Object (readonly)
Returns the value of attribute twitter_api.
10 11 12 |
# File 'lib/twitter_request_headers.rb', line 10 def twitter_api @twitter_api end |
Class Method Details
.configure(consumer_key, consumer_secret, oauth_version = nil, oauth_cipher = nil, twitter_api = nil) ⇒ true
Define Twitter application credentials and options to be accessible from rest of all library.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/twitter_request_headers.rb', line 22 def configure(consumer_key, consumer_secret, oauth_version = nil, oauth_cipher = nil, twitter_api = nil) @consumer_key = consumer_key @consumer_secret = consumer_secret @oauth_version = oauth_version || OAUTH_VERSION @oauth_cipher = oauth_cipher || OAUTH_CIPHER @twitter_api = twitter_api || TWITTER_API @@configured = true end |
Instance Method Details
#header ⇒ Hash
HTTP header of format: => ‘OAuth …’
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/twitter_request_headers.rb', line 63 def header signature = Signature.new( @oauth_token, @oauth_secret, @request_verb, @request_path, @request_params, @nonce, @epochtime ).digest { Header.key => Header.new(@oauth_token, signature, @nonce, @epochtime).value } end |