05.20
The other month I was reading about a MobileMe ’scraper’ class written in PHP called Sosumi. This got my mind rolling…
Since I already have a MobileMe account which provides the ‘Find My iPhone’ feature to check on the (near enough) real-time location of your iPhone, I wanted to make use of this. Now I thought, wouldn’t it be great if you could be checked into Foursquare venues automatically without having to open the app on your iPhone and check in manually. Well, yes, this would be brilliant! However, there’s one major technical limitation. Apple have disallowed any form of background processes for third-party applications. Due to this, it is impossible for the Foursquare app to know your location all of the time without being constantly open all of the time. This would be a major pain as you can rightly imagine.
This is where Sosumi comes into its own. Sosumi is run on a webserver, the same way as any other PHP code. This simply talks to the MobileMe ‘Find My iPhone’ process, which eventually returns a simple pair of latitude and longitude co-ordinates. I went about setting up a CRON script to call the Sosumi script every 5 minutes, which would log into MobileMe and check the location of my iPhone. This worked well. A little too well to be honest! The next step was to talk to the Foursquare API.
I ended up using CURL in PHP to request all venues on Foursquare closest to the co-ordinates Sosumi returned from MobileMe. Here I stumbled upon a problem however. It seemed that the iPhone had a tendency to return duff co-ordinates in some cases, I’m assuming when the phone has been in sleep mode for a good while, and doesn’t update a truly accurate location to MobileMe. Either way, this and the fact my CRON script was running every 5 minutes was causing a lot of random check-ins to all sorts of nearby venues!
I’ve overcome this issue now by reducing the period the CRON job is executed, as well as ensuring that no double check-in occurs if you’re already in the same location. Sosumi is now scraping MobileMe for co-ordinates every 15 minutes, which seems to work well. I’ve also come to the conclusion that if you’re not staying in the same location for more than 15 minutes then it’s pointless checking in at all.
So there you have it! I now benefit from auto check-ins wherever I roam! I’m considering creating a public service now for this so that anyone else who has a MobileMe account can simply enter their login details and that’s it – automated check-ins for all MobileMe iPhone users!
Please share your work. Sounds interesting!