-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitterer.rb
31 lines (26 loc) · 885 Bytes
/
twitterer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class Twitter
include HTTParty
base_uri 'twitter.com'
def initialize(u)
password = ask("Enter Password") {|q| q.echo = false}
@auth = {:username => u, :password => password}
end
# which can be :friends, :user or :public
# options[:query] can be things like since, since_id, count, etc.
def timeline(which=:friends, options={})
options.merge!({:basic_auth => @auth})
self.class.get("/statuses/#{which}_timeline.json", options)
end
def mentions(options={})
options.merge!({:basic_auth => @auth})
self.class.get("/statuses/mentions.json", options)
end
def post(options)
options.merge!({:basic_auth => @auth})
self.class.post('/statuses/update.json', options)
end
def users(which=:show, options={})
options.merge!({:basic_auth => @auth})
self.class.get("/users/#{which}.json", options)
end
end