gleuch-twitter_oauth 0.1.21 → 0.2.1
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.
data/lib/twitter_oauth/client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
+
require 'twitter_oauth/timeline'
|
2
|
+
require 'twitter_oauth/status'
|
1
3
|
require 'twitter_oauth/account'
|
2
|
-
require 'twitter_oauth/statuses'
|
3
4
|
require 'twitter_oauth/direct_messages'
|
4
5
|
require 'twitter_oauth/search'
|
5
6
|
require 'twitter_oauth/notifications'
|
@@ -28,11 +29,6 @@ module TwitterOAuth
|
|
28
29
|
@secret = @access_token.secret
|
29
30
|
@access_token
|
30
31
|
end
|
31
|
-
|
32
|
-
def authentication_request_token
|
33
|
-
consumer.options[:authorize_path] = '/oauth/authenticate'
|
34
|
-
request_token
|
35
|
-
end
|
36
32
|
|
37
33
|
def show(username)
|
38
34
|
oauth_response = access_token.get("/users/show/#{username}.json")
|
@@ -43,6 +39,11 @@ module TwitterOAuth
|
|
43
39
|
consumer.get_request_token(options)
|
44
40
|
end
|
45
41
|
|
42
|
+
def authentication_request_token(options={})
|
43
|
+
consumer.options[:authorize_path] = '/oauth/authenticate'
|
44
|
+
request_token(options)
|
45
|
+
end
|
46
|
+
|
46
47
|
private
|
47
48
|
def consumer
|
48
49
|
@consumer ||= OAuth::Consumer.new(
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module TwitterOAuth
|
2
2
|
class Client
|
3
3
|
|
4
|
-
def friends_ids(
|
5
|
-
|
6
|
-
args = args.reject{|k,v| !allowed.include?(k.to_s.downcase)}.map{|k,v| "#{k}=#{v}"}.join('&')
|
4
|
+
def friends_ids(options={})
|
5
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
7
6
|
oauth_response = access_token.get("/friends/ids.json?#{args}")
|
8
7
|
JSON.parse(oauth_response.body)
|
9
8
|
end
|
10
9
|
|
11
|
-
def followers_ids(
|
12
|
-
|
13
|
-
args = args.reject{|k,v| !allowed.include?(k.to_s.downcase)}.map{|k,v| "#{k}=#{v}"}.join('&')
|
10
|
+
def followers_ids(options={})
|
11
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
14
12
|
oauth_response = access_token.get("/followers/ids.json?#{args}")
|
15
13
|
JSON.parse(oauth_response.body)
|
16
14
|
end
|
data/lib/twitter_oauth/search.rb
CHANGED
@@ -4,8 +4,10 @@ require 'ostruct'
|
|
4
4
|
module TwitterOAuth
|
5
5
|
class Client
|
6
6
|
|
7
|
-
def search(q,
|
8
|
-
|
7
|
+
def search(q, options={})
|
8
|
+
options[:page] ||= 1
|
9
|
+
options[:per_page] ||= 20
|
10
|
+
response = open("http://search.twitter.com/search.json?q=#{URI.escape(q)}&page=#{options[:page]}&rpp=#{options[:per_page]}&since_id=#{options[:since_id]}")
|
9
11
|
search_result = JSON.parse(response.read)
|
10
12
|
search_result = OpenStruct.new(search_result)
|
11
13
|
search_result.results = search_result.results.collect{|x| OpenStruct.new(x)}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module TwitterOAuth
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Returns a single status, specified by the id parameter below.
|
5
|
+
def status(id)
|
6
|
+
oauth_response = access_token.get("/statuses/show/#{id}.json")
|
7
|
+
JSON.parse(oauth_response.body)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Updates the authenticating user's status.
|
11
|
+
def update(message, options={})
|
12
|
+
oauth_response = access_token.post('/statuses/update.json', options.merge(:status => message))
|
13
|
+
JSON.parse(oauth_response.body)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Destroys the status specified by the required ID parameter
|
17
|
+
def status_destroy(id)
|
18
|
+
oauth_response = access_token.post("/statuses/destroy/#{id}.json")
|
19
|
+
JSON.parse(oauth_response.body)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Retweets the tweet specified by the id parameter. Returns the original tweet with retweet details embedded.
|
23
|
+
def retweet(id)
|
24
|
+
oauth_response = access_token.post("/statuses/retweet/#{id}.json")
|
25
|
+
JSON.parse(oauth_response.body)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module TwitterOAuth
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
|
5
|
+
def public_timeline(options={})
|
6
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
7
|
+
oauth_response = access_token.get("/statuses/public_timeline.json?#{args}")
|
8
|
+
JSON.parse(oauth_response.body)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends.
|
12
|
+
# This is the equivalent of /timeline/home on the Web.
|
13
|
+
def home_timeline(options={})
|
14
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
15
|
+
oauth_response = access_token.get("/statuses/home_timeline.json?#{args}")
|
16
|
+
JSON.parse(oauth_response.body)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns the 20 most recent statuses posted by the authenticating user and that user's friends.
|
20
|
+
def friends_timeline(options={})
|
21
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
22
|
+
oauth_response = access_token.get("/statuses/friends_timeline.json?#{args}")
|
23
|
+
JSON.parse(oauth_response.body)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returns the 20 most recent statuses posted from the authenticating user.
|
27
|
+
def user_timeline(options={})
|
28
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
29
|
+
oauth_response = access_token.get("/statuses/user_timeline.json?#{args}")
|
30
|
+
JSON.parse(oauth_response.body)
|
31
|
+
end
|
32
|
+
alias :user :user_timeline
|
33
|
+
|
34
|
+
# Returns the 20 most recent @replies (status updates prefixed with @username) for the authenticating user.
|
35
|
+
def mentions(options={})
|
36
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
37
|
+
oauth_response = access_token.get("/statuses/mentions.json?#{args}")
|
38
|
+
JSON.parse(oauth_response.body)
|
39
|
+
end
|
40
|
+
alias :replies :mentions
|
41
|
+
|
42
|
+
# Returns the 20 most recent retweets posted by the authenticating user
|
43
|
+
def retweeted_by_me(options={})
|
44
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
45
|
+
oauth_response = access_token.get("/statuses/retweeted_by_me.json?#{args}")
|
46
|
+
JSON.parse(oauth_response.body)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns the 20 most recent retweets posted by the authenticating user's friends.
|
50
|
+
def retweeted_to_me(options={})
|
51
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
52
|
+
oauth_response = access_token.get("/statuses/retweeted_to_me.json?#{args}")
|
53
|
+
JSON.parse(oauth_response.body)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
|
57
|
+
def retweets_of_me(options={})
|
58
|
+
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
|
59
|
+
oauth_response = access_token.get("/statuses/retweets_of_me.json?#{args}")
|
60
|
+
JSON.parse(oauth_response.body)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gleuch-twitter_oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Taylor
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: "1.15"
|
45
45
|
version:
|
46
46
|
description: twitter_oauth is a Ruby library for talking to twitter using the new oauth method.
|
47
|
-
email:
|
47
|
+
email: moomerman@gmail.com
|
48
48
|
executables: []
|
49
49
|
|
50
50
|
extensions: []
|
@@ -56,8 +56,9 @@ files:
|
|
56
56
|
- lib/twitter_oauth
|
57
57
|
- lib/twitter_oauth.rb
|
58
58
|
- lib/twitter_oauth/client.rb
|
59
|
+
- lib/twitter_oauth/timeline.rb
|
59
60
|
- lib/twitter_oauth/account.rb
|
60
|
-
- lib/twitter_oauth/
|
61
|
+
- lib/twitter_oauth/status.rb
|
61
62
|
- lib/twitter_oauth/direct_messages.rb
|
62
63
|
- lib/twitter_oauth/search.rb
|
63
64
|
- lib/twitter_oauth/blocks.rb
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module TwitterOAuth
|
2
|
-
class Client
|
3
|
-
|
4
|
-
# Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
|
5
|
-
def public_timeline
|
6
|
-
oauth_response = access_token.get('/statuses/public_timeline.json')
|
7
|
-
JSON.parse(oauth_response.body)
|
8
|
-
end
|
9
|
-
|
10
|
-
# Returns the 20 most recent statuses posted by the authenticating user and that user's friends.
|
11
|
-
def friends_timeline(rpp=20, page=1)
|
12
|
-
oauth_response = access_token.get("/statuses/friends_timeline.json?count=#{rpp}&page=#{page}")
|
13
|
-
JSON.parse(oauth_response.body)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Returns the 20 most recent statuses posted from the authenticating user.
|
17
|
-
def user(page=1)
|
18
|
-
oauth_response = access_token.get("/statuses/user_timeline.json?page=#{page}")
|
19
|
-
JSON.parse(oauth_response.body)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Returns a single status, specified by the id parameter below.
|
23
|
-
def status(id)
|
24
|
-
oauth_response = access_token.get("/statuses/show/#{id}.json")
|
25
|
-
JSON.parse(oauth_response.body)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Updates the authenticating user's status.
|
29
|
-
def update(message)
|
30
|
-
oauth_response = access_token.post('/statuses/update.json', :status => message)
|
31
|
-
JSON.parse(oauth_response.body)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Returns the 20 most recent @replies (status updates prefixed with @username) for the authenticating user.
|
35
|
-
def replies(page=1)
|
36
|
-
oauth_response = access_token.get("/statuses/mentions.json?page=#{page}")
|
37
|
-
JSON.parse(oauth_response.body)
|
38
|
-
end
|
39
|
-
|
40
|
-
# alias
|
41
|
-
def mentions
|
42
|
-
replies
|
43
|
-
end
|
44
|
-
|
45
|
-
# Destroys the status specified by the required ID parameter
|
46
|
-
def status_destroy(id)
|
47
|
-
oauth_response = access_token.post("/statuses/destroy/#{id}.json")
|
48
|
-
JSON.parse(oauth_response.body)
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|