rcarver-twitter 0.5.4

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/History ADDED
@@ -0,0 +1,154 @@
1
+ 0.5.3 - April 10, 2009
2
+ * 1 minor fix
3
+ * Twitter API assumed follow true whether true or false. Now only sending follow along to request if follow is true for calls to friendship_create.
4
+
5
+ 0.5.2 - April 8, 2009
6
+ * 4 minor fixes
7
+ * added mash as an install dependency, forgot it initially
8
+ * fixed that search wasn't taking into account a bunch of options duh!
9
+ * fixed some missing vars and stuff in exception raising
10
+ * added development dependencies to rake file to make that more explicit (technomancy)
11
+ * lame workaround for Mash#hash that allows using return objects in sets and such (technomancy)
12
+
13
+ 0.5.1 - April 5, 2009
14
+ * 1 minor change
15
+ * Added data error hash returned from twitter to a few of the exceptions to help with debugging
16
+ * Fixed friendship_exists?. Was throwing mash stringify keys error because it was returning true or false instead of hash or array.
17
+
18
+ 0.5.0 - April 3, 2009
19
+ * 1 major rewrite for OAuth
20
+ * Backwards compatibility thrown to the wind
21
+ * Proxy no longer supported (someone please add it back in, I never use proxies)
22
+ * Identica support killed with an axe (nothing against them but I don't use it)
23
+ * CLI shot to death (will be reborn at a later date using oauth and its own gem)
24
+
25
+ 0.4.3 - February 21, 2009
26
+ * 1 minor enhancement
27
+ * verify_credentials now returns a Twitter::User rather than an hpricot doc
28
+
29
+ 0.4.2 - February 10, 2009
30
+ * 1 minor enhancement
31
+ * Adding the Social Graph API methods (Josh Owens)
32
+
33
+ 0.4.1 - January 1, 2009
34
+ * 4 minor enhancements and 2 bug fixes:
35
+ * Added better exception handling (Billy Gray)
36
+ * Added page to search (Michael Ivey)
37
+ * Adding an option to display tweets on CLI in reverse order (oldest first). (Cameron Booth)
38
+ * Added in_reply_to_status_id option for replying to statuses (anthonycrumley)
39
+ * Fixed a bug where the @config was improperly set (K. Adam Christensen)
40
+ * Fix verify_credentials to include a format (breaks in laconica). (dustin)
41
+
42
+ 0.4.0 - December 23, 2008
43
+ * 3 major changes
44
+ * Removed active support as dependency
45
+ * Removed CLI dependencies from install dependency list
46
+ (they are now only installed by you manually)
47
+ * Switched to echoe for gem managment
48
+
49
+ 0.3.7 - August 26, 2008
50
+ * Fixed source param not getting through
51
+
52
+ 0.3.6 - August 11, 2008
53
+ * Fixed a few more methods that required post.
54
+ * Refactored the remaining methods that were not using #request to use it.
55
+
56
+ 0.3.5 - August 4, 2008
57
+ * Removed sqlite-ruby 1.2.2 as a dependency due to install issues on linux
58
+
59
+ 0.3.4 - August 3, 2008
60
+ * Added search support
61
+
62
+ 0.3.3 - August 3, 2008
63
+ * Now has option for host when initializing to support identi.ca (Dustin Sallings)
64
+ * Twitter changed a bunch of methods to POST only so I updated those to now work
65
+
66
+ 0.3.2 - July 26, 2008
67
+ * added the CLI gems as dependencies for now until I separate out the CLI from the API wrapper
68
+ * cleaner CLI errors for no active account or no accounts at all
69
+ * remove sets a new active account if there are none
70
+ * added username and password optional arguments to add
71
+ * added import attempt on install and on anything that uses #current_account helper
72
+
73
+ 0.3.1 - July 23, 2008
74
+ * added open to CLI twitter open jnunemaker would open default browser to http://twitter.com/jnunemaker
75
+ * added -f to timeline and replies which ignores the since_id and shows all results
76
+ * added clear_config to remove all cached since id's and such
77
+ * Majorly pimped the output of timelines and replies.
78
+
79
+ 0.3.0 - July 22, 2008
80
+ * complete rewrite of CLI. Now supports multiple accounts and changing between them.
81
+ * added source, truncated, in_reply_to_status_id, in_reply_to_user_id, and favorited to Twitter::Status
82
+ * added protected to Twitter::User
83
+ * d CLI method now takes standard input like post
84
+ * Rewrote several methods that had since parameter to now use a hash instead. This makes it more flexible as API updates.
85
+ * Rewrote the methods that took lite or since as an argument to instead take a hash.
86
+ * added Twitter::Base#friendship_exists?
87
+ * added Twitter::Base#update_location
88
+ * added Twitter::Base#update_delivery_device
89
+ * added Twitter::Base#favorites
90
+ * added Twitter::Base#create_favorite
91
+ * added Twitter::Base#destroy_favorite
92
+ * added Twitter::Base#block
93
+ * added Twitter::Base#unblock
94
+
95
+ BACKWORDS COMPATIBILITY BREAK:
96
+ Any method that you have using lite or since as an argument
97
+ will no longer work with this version. Simply change to a
98
+ hash and you'll be fine. For example:
99
+
100
+ friends(true) would now be friends(:lite => true)
101
+
102
+ 0.2.7 - June 29, 2008
103
+ * added #rate_limit_status (Daniel Morrison)
104
+ * added source parameter option to Base#post
105
+ * added twittergem as source when posting from command line
106
+ * Twitter::RateExceeded raised when you hit your limit (Jim O'Leary)
107
+ * Twitter::Unavailable raised when twitter returns 503
108
+ * Twitter::CantConnect is now more descriptive as to what is the problem when it is raised during a request
109
+ * quoting your message when using twitter post on the command line is now optional (Benoit Caccinolo)
110
+ * aliased post to p on command line so it's shorter (Benoit Caccinolo)
111
+ * unescaped html and added some color in command line view (Miles Z. Sterrett)
112
+ * added gemspec (technoweenie, Miles Z. Sterrett)
113
+ * Fixed stack trace error on first command line operation (Matt Rose)
114
+ 0.2.6 - April 2, 2008
115
+ * found a more simple way of doing stdin without any extra gem dependencies
116
+ 0.2.5 - April 2, 2008
117
+ * Command line interface can now use stdin for posting (ideas and example code from Jeremy Friesen)
118
+ $ twitter post 'test without stdin' # => twitters: test without stdin
119
+ $ echo 'test with stdin' | twitter post 'and an argv[1]' # => twitters: test with stdin and an argv[1]
120
+ $ echo 'test with stdin without any argv[1]' | twitter post # => twitters: test with stdin without any argv[1]
121
+ 0.2.4 - Mar 31, 2008
122
+ * Added lite option to friends and followers, which doesn't include the user's current status (Daniel Morrison)
123
+ * Updated since option to use HTTP header, and added the option on timeline() and replies(). (Daniel Morrison)
124
+ 0.2.3 - Jan 16, 2008
125
+ * added d to command line interface twitter d jnunemaker 'hola' (Humbucker)
126
+ * added progress dots when posting for confirmation when twitter is running slow (Hendy Irawan)
127
+ 0.2.2 - added leave and follow which are new twitter api methods for turning notifications on and off
128
+ 0.2.0 - Aug 4, 2007
129
+ * added sent_messages
130
+ * alias direct_messages to received_messages
131
+ * added create_friendship
132
+ * added destroy_friendship
133
+ * added featured to retrieve the featured twitter users
134
+ * added replies
135
+ * added destroy to destroy a status by id
136
+ * added status to find a status by id
137
+ * added active support as an extra dependency
138
+ * implemented d method to send direct messages (jnewland)
139
+ * fixed since argument in direct_messages method (jnewland)
140
+ 0.1.1 - May 20, 2007
141
+ * hpricot 0.5+ now supported; just a bug fix (Ryan Waldron is the man!)
142
+ 0.1.0 - March 31, 2007
143
+ * added d method for creating direct messages (waiting for it to work as documented)
144
+ * added featured method for getting featured users statuses (waiting for it to work as documented)
145
+ * added direct_messages method
146
+ * added friends_for method
147
+ * added a few tests
148
+ * removed relative_created_at as it is deprecated
149
+ * separated out the call method into call, request and parse methods
150
+ 0.0.5 - just a bit of code cleanup
151
+ 0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne)
152
+ 0.0.3 - added a bit more informative message when things go wrong
153
+ 0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs
154
+ 0.0.1 - initial release
data/License ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 John Nunemaker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Notes ADDED
@@ -0,0 +1,33 @@
1
+ *****************************************************************
2
+ * From Twitter API Docs, so I don't have to keep going to them. *
3
+ *****************************************************************
4
+
5
+ http://apiwiki.twitter.com/REST+API+Documentation
6
+
7
+ 200 OK: everything went awesome.
8
+ 304 Not Modified: there was no new data to return.
9
+ 400 Bad Request: your request is invalid, and we'll return an error message that tells you why. This is the status code returned if you've exceeded the rate limit (see below).
10
+ 401 Not Authorized: either you need to provide authentication credentials, or the credentials provided aren't valid.
11
+ 403 Forbidden: we understand your request, but are refusing to fulfill it. An accompanying error message should explain why.
12
+ 404 Not Found: either you're requesting an invalid URI or the resource in question doesn't exist (ex: no such user).
13
+ 500 Internal Server Error: we did something wrong. Please post to the group about it and the Twitter team will investigate.
14
+ 502 Bad Gateway: returned if Twitter is down or being upgraded.
15
+ 503 Service Unavailable: the Twitter servers are up, but are overloaded with requests. Try again later.
16
+
17
+ **********
18
+ * Errors *
19
+ **********
20
+
21
+ <?xml version="1.0" encoding="UTF-8"?>
22
+ <hash>
23
+ <request>/direct_messages/destroy/456.xml</request>
24
+ <error>No direct message with that ID found.</error>
25
+ </hash>
26
+
27
+ **********************
28
+ * Rate Limit Headers *
29
+ **********************
30
+
31
+ X-RateLimit-Limit the current limit in effect
32
+ X-RateLimit-Remaining the number of hits remaining before you are rate limited
33
+ X-RateLimit-Reset the time the current rate limiting period ends (in epoch time, number of seconds since 1970-01-01 00:00:00)
data/README.rdoc ADDED
@@ -0,0 +1,9 @@
1
+ = twitter
2
+
3
+ The ruby twitter gem. The gem heard round the world and famous on the streets. Haha.
4
+
5
+ For now this is just an API wrapper. The command line interface is temporarily dead until I have time to make it work with oauth. At that point, I'll make it a new gem twitter-cli or something and it will depend on this gem to work. That will keep the separation of the api wrapper and cli and fix a lot of dependency issues.
6
+
7
+ == Copyright
8
+
9
+ Copyright (c) 2009 John Nunemaker. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,103 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "twitter"
8
+ gem.summary = %Q{wrapper for the twitter api (oauth only)}
9
+ gem.email = "nunemaker@gmail.com"
10
+ gem.homepage = "http://github.com/jnunemaker/twitter"
11
+ gem.authors = ["John Nunemaker"]
12
+ gem.rubyforge_project = "twitter"
13
+ gem.files = FileList["[A-Z]*", "{examples,lib,test}/**/*"]
14
+
15
+ gem.add_dependency('oauth')
16
+ gem.add_dependency('extlib')
17
+ gem.add_dependency('httparty', '>= 0.4.2')
18
+
19
+ gem.add_development_dependency('thoughtbot-shoulda')
20
+ gem.add_development_dependency('jeremymcanally-matchy')
21
+ gem.add_development_dependency('mocha')
22
+ gem.add_development_dependency('fakeweb')
23
+ gem.add_development_dependency('extlib')
24
+ end
25
+ rescue LoadError
26
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
27
+ end
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/*_test.rb'
33
+ test.verbose = false
34
+ end
35
+
36
+ begin
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new do |test|
39
+ test.libs << 'test'
40
+ test.pattern = 'test/**/*_test.rb'
41
+ test.verbose = true
42
+ end
43
+ rescue LoadError
44
+ task :rcov do
45
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
46
+ end
47
+ end
48
+
49
+
50
+ task :default => :test
51
+
52
+ require 'rake/rdoctask'
53
+ Rake::RDocTask.new do |rdoc|
54
+ if File.exist?('VERSION.yml')
55
+ config = YAML.load(File.read('VERSION.yml'))
56
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
57
+ else
58
+ version = ""
59
+ end
60
+
61
+ rdoc.rdoc_dir = 'rdoc'
62
+ rdoc.title = "twitter #{version}"
63
+ rdoc.rdoc_files.include('README*')
64
+ rdoc.rdoc_files.include('lib/**/*.rb')
65
+ end
66
+
67
+ begin
68
+ require 'rake/contrib/sshpublisher'
69
+ namespace :rubyforge do
70
+
71
+ desc "Release gem and RDoc documentation to RubyForge"
72
+ task :release => ["rubyforge:release:gem", "rubyforge:release:website", "rubyforge:release:docs"]
73
+
74
+ namespace :release do
75
+ desc "Publish RDoc to RubyForge."
76
+ task :docs => [:rdoc] do
77
+ config = YAML.load(
78
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
79
+ )
80
+
81
+ host = "#{config['username']}@rubyforge.org"
82
+ remote_dir = "/var/www/gforge-projects/twitter/rdoc"
83
+ local_dir = 'rdoc'
84
+
85
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
86
+ end
87
+
88
+ task :website do
89
+ config = YAML.load(
90
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
91
+ )
92
+
93
+ host = "#{config['username']}@rubyforge.org"
94
+ remote_dir = "/var/www/gforge-projects/twitter/"
95
+ local_dir = 'website'
96
+
97
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
98
+ end
99
+ end
100
+ end
101
+ rescue LoadError
102
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
103
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 5
4
+ :patch: 4
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
7
+
8
+ if config['atoken'] && config['asecret']
9
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
10
+ twitter = Twitter::Base.new(oauth)
11
+ pp twitter.friends_timeline
12
+
13
+ elsif config['rtoken'] && config['rsecret']
14
+ oauth.authorize_from_request(config['rtoken'], config['rsecret'])
15
+ twitter = Twitter::Base.new(oauth)
16
+ pp twitter.friends_timeline
17
+
18
+ config.update({
19
+ 'atoken' => oauth.access_token.token,
20
+ 'asecret' => oauth.access_token.secret,
21
+ }).delete('rtoken', 'rsecret')
22
+ else
23
+ config.update({
24
+ 'rtoken' => oauth.request_token.token,
25
+ 'rsecret' => oauth.request_token.secret,
26
+ })
27
+
28
+ # authorize in browser
29
+ %x(open #{oauth.request_token.authorize_url})
30
+ end
@@ -0,0 +1,13 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
8
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
9
+
10
+ client = Twitter::Base.new(oauth)
11
+
12
+ puts client.friendship_exists?('jnunemaker', 'orderedlist')
13
+ puts client.friendship_exists?('jnunemaker', 'biz')
@@ -0,0 +1,38 @@
1
+ class ConfigStore
2
+ attr_reader :file
3
+
4
+ def initialize(file)
5
+ @file = file
6
+ end
7
+
8
+ def load
9
+ @config ||= YAML::load(open(file))
10
+ self
11
+ end
12
+
13
+ def [](key)
14
+ load
15
+ @config[key]
16
+ end
17
+
18
+ def []=(key, value)
19
+ @config[key] = value
20
+ end
21
+
22
+ def delete(*keys)
23
+ keys.each { |key| @config.delete(key) }
24
+ save
25
+ self
26
+ end
27
+
28
+ def update(c={})
29
+ @config.merge!(c)
30
+ save
31
+ self
32
+ end
33
+
34
+ def save
35
+ File.open(file, 'w') { |f| f.write(YAML.dump(@config)) }
36
+ self
37
+ end
38
+ end
@@ -0,0 +1,15 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require 'pp'
3
+
4
+ search = Twitter::Search.new.from('jnunemaker')
5
+
6
+ puts '*'*50, 'First Run', '*'*50
7
+ search.each { |result| pp result }
8
+
9
+ puts '*'*50, 'Second Run', '*'*50
10
+ search.each { |result| pp result }
11
+
12
+ puts '*'*50, 'Parameter Check', '*'*50
13
+ pp Twitter::Search.new('#austineats').fetch().results.first
14
+ pp Twitter::Search.new('#austineats').page(2).fetch().results.first
15
+ pp Twitter::Search.new('#austineats').since(1412737343).fetch().results.first
@@ -0,0 +1,19 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
8
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
9
+
10
+ client = Twitter::Base.new(oauth)
11
+
12
+ pp client.friends_timeline
13
+ puts '*'*50
14
+
15
+ pp client.user_timeline
16
+ puts '*'*50
17
+
18
+ pp client.replies
19
+ puts '*'*50
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'twitter')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.twitter")
6
+
7
+ oauth = Twitter::OAuth.new(config['token'], config['secret'])
8
+ oauth.authorize_from_access(config['atoken'], config['asecret'])
9
+
10
+ client = Twitter::Base.new(oauth)
11
+ pp client.update('This is an update from the twitter gem')
@@ -0,0 +1,163 @@
1
+ module Twitter
2
+ class Base
3
+ extend Forwardable
4
+
5
+ def_delegators :@client, :get, :post
6
+
7
+ def initialize(oauth)
8
+ @client = oauth.access_token
9
+ end
10
+
11
+ # Options: since_id, max_id, count, page, since
12
+ def friends_timeline(query={})
13
+ perform_get('/statuses/friends_timeline.json', :query => query)
14
+ end
15
+
16
+ # Options: id, user_id, screen_name, since_id, max_id, page, since
17
+ def user_timeline(query={})
18
+ perform_get('/statuses/user_timeline.json', :query => query)
19
+ end
20
+
21
+ def status(id)
22
+ perform_get("/statuses/show/#{id}.json")
23
+ end
24
+
25
+ # Options: in_reply_to_status_id
26
+ def update(status, query={})
27
+ perform_post("/statuses/update.json", :body => {:status => status}.merge(query))
28
+ end
29
+
30
+ # Options: since_id, max_id, since, page
31
+ def replies(query={})
32
+ perform_get('/statuses/replies.json', :query => query)
33
+ end
34
+
35
+ def status_destroy(id)
36
+ perform_post("/statuses/destroy/#{id}.json")
37
+ end
38
+
39
+ # Options: id, user_id, screen_name, page
40
+ def friends(query={})
41
+ perform_get('/statuses/friends.json', :query => query)
42
+ end
43
+
44
+ # Options: id, user_id, screen_name, page
45
+ def followers(query={})
46
+ perform_get('/statuses/followers.json', :query => query)
47
+ end
48
+
49
+ def user(id)
50
+ perform_get("/users/show/#{id}.json")
51
+ end
52
+
53
+ # Options: since, since_id, page
54
+ def direct_messages(query={})
55
+ perform_get("/direct_messages.json", :query => query)
56
+ end
57
+
58
+ # Options: since, since_id, page
59
+ def direct_messages_sent(query={})
60
+ perform_get("/direct_messages/sent.json", :query => query)
61
+ end
62
+
63
+ def direct_message_create(user, text)
64
+ perform_post("/direct_messages/new.json", :body => {:user => user, :text => text})
65
+ end
66
+
67
+ def direct_message_destroy(id)
68
+ perform_post("/direct_messages/destroy/#{id}.json")
69
+ end
70
+
71
+ def friendship_create(id, follow=false)
72
+ body = {}
73
+ body.merge!(:follow => follow) if follow
74
+ perform_post("/friendships/create/#{id}.json", :body => body)
75
+ end
76
+
77
+ def friendship_destroy(id)
78
+ perform_post("/friendships/destroy/#{id}.json")
79
+ end
80
+
81
+ def friendship_exists?(a, b)
82
+ perform_get("/friendships/exists.json", :query => {:user_a => a, :user_b => b})
83
+ end
84
+
85
+ # Options: id, user_id, screen_name
86
+ def friend_ids(query={})
87
+ perform_get("/friends/ids.json", :query => query)
88
+ end
89
+
90
+ # Options: id, user_id, screen_name
91
+ def friend_ids(query={})
92
+ perform_get("/followers/ids.json", :query => query)
93
+ end
94
+
95
+ def verify_credentials
96
+ perform_get("/account/verify_credentials.json")
97
+ end
98
+
99
+ # Device must be sms, im or none
100
+ def update_delivery_device(device)
101
+ perform_post('/account/update_delivery_device.json', :body => {:device => device})
102
+ end
103
+
104
+ # One or more of the following must be present:
105
+ # profile_background_color, profile_text_color, profile_link_color,
106
+ # profile_sidebar_fill_color, profile_sidebar_border_color
107
+ def update_profile_colors(colors={})
108
+ perform_post('/account/update_profile_colors.json', :body => colors)
109
+ end
110
+
111
+ def rate_limit_status
112
+ perform_get('/account/rate_limit_status.json')
113
+ end
114
+
115
+ # One or more of the following must be present:
116
+ # name, email, url, location, description
117
+ def update_profile(body={})
118
+ perform_post('/account/update_profile.json', :body => body)
119
+ end
120
+
121
+ # Options: id, page
122
+ def favorites(query={})
123
+ perform_get('/favorites.json', :query => query)
124
+ end
125
+
126
+ def favorite_create(id)
127
+ perform_post("/favorites/create/#{id}.json")
128
+ end
129
+
130
+ def favorite_destroy(id)
131
+ perform_post("/favorites/destroy/#{id}.json")
132
+ end
133
+
134
+ def enable_notifications(id)
135
+ perform_post("/notifications/follow/#{id}.json")
136
+ end
137
+
138
+ def disable_notifications(id)
139
+ perform_post("/notifications/leave/#{id}.json")
140
+ end
141
+
142
+ def block(id)
143
+ perform_post("/blocks/create/#{id}.json")
144
+ end
145
+
146
+ def unblock(id)
147
+ perform_post("/blocks/destroy/#{id}.json")
148
+ end
149
+
150
+ def help
151
+ perform_get('/help/test.json')
152
+ end
153
+
154
+ private
155
+ def perform_get(path, options={})
156
+ Twitter::Request.get(self, path, options)
157
+ end
158
+
159
+ def perform_post(path, options={})
160
+ Twitter::Request.post(self, path, options)
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,31 @@
1
+ module Twitter
2
+ class OAuth
3
+ attr_reader :ctoken, :csecret
4
+
5
+ def initialize(ctoken, csecret)
6
+ @ctoken, @csecret = ctoken, csecret
7
+ end
8
+
9
+ def consumer
10
+ @consumer ||= ::OAuth::Consumer.new(@ctoken, @csecret, {:site => 'http://twitter.com'})
11
+ end
12
+
13
+ def request_token
14
+ @request_token ||= consumer.get_request_token
15
+ end
16
+
17
+ def authorize_from_request(rtoken, rsecret)
18
+ request_token = ::OAuth::RequestToken.new(consumer, rtoken, rsecret)
19
+ access_token = request_token.get_access_token
20
+ @atoken, @asecret = access_token.token, access_token.secret
21
+ end
22
+
23
+ def access_token
24
+ @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret)
25
+ end
26
+
27
+ def authorize_from_access(atoken, asecret)
28
+ @atoken, @asecret = atoken, asecret
29
+ end
30
+ end
31
+ end