Foursquare now is the most important location-based social network and used by many of my contacts. And Ruby, like for every social network offer libraries that can help developer to be more productive. Foursquare is now available as an API using basic authentication or Oauth, for more information documentation.
For Library, GEM’s are available, one of them “foursquare-ruby-api” can do for you what you want.
To install :

  1. $ sudo gem install foursquare-ruby-api

Next, you can write your code to do what you want.
To begin this sample, we must know some useful methods :

  • Checkins : Returns a list of recent checkins from friends.
  • Check-in : Allows you to check-in to a place.
  • History : Returns a history of checkins for the authenticated user.

For more information, Very rich documentation are available with ideas about parameters and results structures.
And our Example will be a list of recent checkins from our friends:

  1. require ‘rubygems’
  2. gem (‘foursquare-ruby-api’)
  3. require ‘foursquare’
  4. fq =’email’,‘password’)
  5. # fq.test is optional to test our connexion
  6. fq.test
  7. fq.checkins()[‘checkins’][‘checkin’].each do |f|
  8.    puts f[‘display’]+"   "+f[‘created’]
  9. end

For more information :

PS: This api can be used as a hack to be mayor for many places from your house or office 😀