Installation
gem install twitter
Mailing List
Please direct any questions about the library to the mailing list.
Usage Examples
Return @sferik's location
Twitter.user("sferik").location
Return @sferik's most recent Tweet
Twitter.user_timeline("sferik").first.text
Return the text of the Tweet at https://twitter.com/sferik/statuses/27558893223
Twitter.status(27558893223).text
Find the 3 most recent marriage proposals to @justinbieber
Twitter.search("to:justinbieber marry me", :rpp => 3, :result_type => "recent").map do |status|
"#{status.from_user}: #{status.text}"
end
Let's find a Japanese-language Tweet tagged #ruby (no retweets)
Twitter.search("#ruby -rt", :lang => "ja", :rpp => 1).first.text
Certain methods require authentication. To get your Twitter OAuth credentials, register an app at http://dev.twitter.com/apps
Twitter.configure do |config|
config.consumer_key = YOUR_CONSUMER_KEY
config.consumer_secret = YOUR_CONSUMER_SECRET
config.oauth_token = YOUR_OAUTH_TOKEN
config.oauth_token_secret = YOUR_OAUTH_TOKEN_SECRET
end
Update your status
Twitter.update("I'm tweeting with @gem!")
Read the most recent Tweet in your timeline
Twitter.home_timeline.first.text
Get your rate limit status
Twitter.rate_limit_status.remaining_hits.to_s + " Twitter API request(s) remaining this hour"