Flying memes

I’ve just checked in at WC2010 Johannesburg Stadium from home

Thanks to Uncle Pear suggestion I realized that you can easily check-in in every Foursquare venue simply invoking its id using the API, to try this behavior I checked in at Johannesburg  WC2010 stadium from my home in Italy.

Here’s the simple snippet of code you can use (from a linux shell):

curl -u -d "vid=4762107"

Foursquare api are really easy to use and lets you invoke up to 200 times each method each hour, so a quite simple exercise can be write a simple program that automatically check-in a selected account in a given array of locations:

require 'rubygems'
require 'restclient'
require 'nokogiri'

counter = -1
debug   = true

travel = [
            # minutes to wait, venue to check-in
            [5 ,4762107],

RestClient.add_before_execution_proc do |req, params|
    req.basic_auth '', 'my_password'

loop do
    time, venue_id = travel[counter = ((counter + 1) % travel.size)]
    puts "sleeping #{time} minutes.." if debug
    sleep time * 60
    response = "", :vid=>venue_id
    puts  ['checkin','message'].inject(Nokogiri::XML(response.body)) { |s,r| s.send(:at, r) }.inner_text

By invoking this code an infinite loop will check-in the provided account into each of the given venues waiting a configurable amount of time between each of them.

Here’s the result:

sandropaganotti$ ruby venue.rb
sleeping 5 minutes..
OK! We've got you @ WC2010 Soccer City Stadium. This is your 2nd checkin here!
sleeping 10 minutes..
OK! We've got you @ Service Station Cafe. This is your 1st checkin here!
sleeping 5 minutes..