After Twitter.com added a few extra APIs for favoriting statuses in October, I finally got around to adding them to Twitter4R tonight. Since there is new functionality I have released it as version 0.3.0.
To install all you need to do is:
$ sudo gem install twitter4rThe Rubyforge mirrors might still be syncing if you are doing this soon after I post this message.
The changes to the library include:
- Added
Twitter::Client#authenticate?method that is a lightweight way to verify a Twitter user's credentials - Favorites: allows Twitterers to add statuses to their favorites, list all their current favorites and remove any statuses from the list.
Example code for verifying a user would look like:
gem('twitter4r', '>=0.3.0')
require('twitter')
client = Twitter::Client.new
unless client.authenticate?("macdeveloperthatlovesleopard", "iamasciolists")
puts "Password does not describe user well!"
end
if client.authenticate?("developerthatdoesnotpretendtobegraphicdesigner", "seriousdevelopernotfakestevejobswannabe")
puts "Password does describe user well!"
endExample code for using the favorites API:
gem('twitter4r', '>=0.3.0')
require('twitter')
require('twitter/console')
client = Twitter::Client.from_config('some/path.yml')
statuses = client.favorites
ids = statuses.collect {|s| s.id }
# clean favorites list by deleting
statuses.each {|s| client.favorite(:remove, s) }
# now add back first status id from original favorites list
client.favorite(:add, ids[0])
Enjoy!