twitter-request-headers 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/lib/twitter_request_headers.rb +26 -1
- data/twitter-request-headers.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3bf20f690c4b4a250baba42d7baf843394e4f75
|
4
|
+
data.tar.gz: 64af4aa26e9fb1e5291ff83155479913191031d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e99a231ea9c1066646624c1956c6bccc5ccf47b9e77768e9417c809b613777579593cad2798b2a91feae6e39094bbf5e09ca66ce9983d51b101ce49c15260c00
|
7
|
+
data.tar.gz: 4fbf4196185d3cc5aff17e145f0b821a782fa48131a70cf36eb956afd83b393e262237b21b19ecbc44620d311f06d74deca074028ab81294bea76fb5b5d21a90
|
data/README.md
CHANGED
@@ -9,6 +9,16 @@ class TwitterRequestHeaders
|
|
9
9
|
class << self
|
10
10
|
attr_reader :consumer_key, :consumer_secret, :oauth_version, :oauth_cipher, :twitter_api
|
11
11
|
|
12
|
+
# Define Twitter application credentials and options to
|
13
|
+
# be accessible from rest of all library.
|
14
|
+
#
|
15
|
+
# @param consumer_key [String] Application ID/Key
|
16
|
+
# @param consumer_secret [String] Application Secret
|
17
|
+
# @param oauth_version [String, nil] OAuth version used by Twitter. See dashboard.
|
18
|
+
# @param oauth_cipher [String, nil] OAuth chipher used by Twitter. See API docs.
|
19
|
+
# @param twitter_api [String, nil] Twitter API address. See dashboard.
|
20
|
+
# @return [true]
|
21
|
+
#
|
12
22
|
def configure(consumer_key, consumer_secret, oauth_version = nil, oauth_cipher = nil, twitter_api = nil)
|
13
23
|
@consumer_key = consumer_key
|
14
24
|
@consumer_secret = consumer_secret
|
@@ -21,7 +31,14 @@ class TwitterRequestHeaders
|
|
21
31
|
end
|
22
32
|
end
|
23
33
|
|
24
|
-
|
34
|
+
# Creates new session.
|
35
|
+
#
|
36
|
+
# @param oauth_token [String] Twitter OAuth Key
|
37
|
+
# @param oauth_secret [String] Twitter OAuth Secret
|
38
|
+
# @param request_verb [String] HTTP verb: GET, POST, e.g.
|
39
|
+
# @param request_path [String] HTTP request path. Like /users/blah/blah
|
40
|
+
# @param request_params [Hash, nil] HTTP request query. Like {user_id: 111222333}
|
41
|
+
#
|
25
42
|
def initialize(oauth_token, oauth_secret, request_verb, request_path, request_params = nil)
|
26
43
|
unless @@configured
|
27
44
|
fail StandardError, "Call #{self.class}.configure first!"
|
@@ -38,6 +55,11 @@ class TwitterRequestHeaders
|
|
38
55
|
@epochtime = epochtime
|
39
56
|
end
|
40
57
|
|
58
|
+
# HTTP header of format:
|
59
|
+
# {'Authorization' => 'OAuth ...'}
|
60
|
+
#
|
61
|
+
# @return [Hash]
|
62
|
+
#
|
41
63
|
def header
|
42
64
|
signature = Signature.new(
|
43
65
|
@oauth_token,
|
@@ -60,6 +82,9 @@ class TwitterRequestHeaders
|
|
60
82
|
SecureRandom.hex(16)
|
61
83
|
end
|
62
84
|
|
85
|
+
# Current unixtime (seconds)
|
86
|
+
# @return [String] 1446639000
|
87
|
+
#
|
63
88
|
def epochtime
|
64
89
|
Time.now.to_i.to_s
|
65
90
|
end
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "twitter-request-headers"
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.12'
|
8
8
|
spec.authors = ["Dmitrii Komaritckii"]
|
9
9
|
spec.email = ["lochnessathome@gmail.com"]
|
10
10
|
|