31 October 2009
Filed under Blog

New in the Twitter gem: Lists!

I believe Twitter's new list feature is big. In fact, I like the idea so much we built our own list of US congressfolk last year. Now, opportunities abound for everyone to share their favorite tweeters in topical lists.

While the Lists API is still in alpha draft status, I couldn't resist baking in some of these new features into the Twitter gem from John Nunemaker.

What's new

New in version 0.7.0 is the ability to:

  • View a user's lists
  • View a list members
  • Create, update, delete lists
  • Add/remove list members
  • Subscribe/unsubscribe from a list

Some examples

# authenticate via basic auth
httpauth = Twitter::HTTPAuth.new('username', 'password')
client = Twitter::Base.new(httpauth)

# get all my lists
client.lists('pengwynn')

# get list info
list = client.list('pengwynn', 'rubyists')
pp list.member_count
# => 2

# view all the members for a list
client.list_members('pengwynn', 'rubyists')

So if you've got plans of incorporating Twitter lists into your Ruby app,

gem install twitter

and get busy!

Like this? Why not grab the feed?