Skip to content

Instantly share code, notes, and snippets.

@ahmdrefat
Created November 12, 2012 13:25
Show Gist options
  • Save ahmdrefat/4903e5d7780349be3811 to your computer and use it in GitHub Desktop.
Save ahmdrefat/4903e5d7780349be3811 to your computer and use it in GitHub Desktop.
# Applications that make requests on behalf of a single Twitter user can pass global configuration options as a block to the Twitter.configure method.
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
# After configuration, requests can be made like so:
Twitter.update("I'm tweeting with @gem!")
# Follow a user
Twitter.follow("ahmdrefat")
# Fetch a user
Twitter.user("ahmdrefat")
# User timeline
Twitter.user_timeline("ahmdrefat")
# Search
Twitter.search("to:ahmdrefat ruby on rails", :count => 5, :result_type => "recent").results.map do |status|
"#{status.from_user}: #{status.text}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment