Skip to content

Instantly share code, notes, and snippets.

@hoverbird
Created March 3, 2010 03:00
Show Gist options
  • Save hoverbird/320261 to your computer and use it in GitHub Desktop.
Save hoverbird/320261 to your computer and use it in GitHub Desktop.
require "twitter"
myname = "hoverbird"
pw = "secretpasswordhere"
auth = Twitter::HTTPAuth.new(myname, pw)
t = Twitter::Base.new(auth)
# If your client (stored in the variable t) is connected, this should work
me = t.user(myname)
# use pp for better readability
pp me
# Checking following status
t.friendship_exists?(myname, "oprah")
t.friendship_exists?("oprah", "ev")
# tweeting
t.update("This string will be my next tweet, use with care!")
# Some timelines
mytweets = t.user_timeline
friendstweets = t.friends_timeline
replies = t.replies
# Trends
trends = Twitter::Trends.current
trends = Twitter::Trends.current(:exclude => 'hashtags')
#Search
# ( the syntax here is a little advanced, don't worry too much if it doesn't make sense yet )
justin = "justinbieber"
search = Twitter::Search.new('marry me').collect
search = Twitter::Search.new("marry me").to(justin).collect
search = Twitter::Search.new('marry me').to(justin).collect {|tweet| tweet.text }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment