Mobile webapp in one day - 4sqNoGPS

Sep 04, 2010 02:19

I did enough weeding yesterday evening to fill two trash bags, but then I got a bit dizzy because some of the weeds were noxious. So I fell asleep before dinner and was wide awake in the middle of the night. That usually is a prelude to high productivity. First, I worked on converting my Twitter scripts to OAuth. I was a bit overdue since Twitter turned off Basic authentication on August 31, but these aren't utilities that I use every day. The main stumbling block was looking for an OAuth library that didn't make things unnecessarily complicated. I found one that's simple enough: oauthConsumer.py by AppHacker. However, it's written in Python but my scripts are in Perl. No biggie. It was actually pretty straightforward to rewrite those in Python once I got up to speed. (I don't use Python very often so every time I pick it up, I have to take a refresher on common Python idioms.)

That only took me to 6am. What else was I going to do today? How about a new project? Enter 4sqNoGPS... (You need a Foursquare account to see it because it starts with the OAuth handshake.)

It's a replacement for Foursquare mobile that is optimized for my handset. (or, as Ericles put it, the smartest non-smart phone :) ) There are numerous problems with Foursquare mobile:
  1. It is slow. What exactly is a mobile website doing with Javascript libraries anyway?
  2. It sends you through too many screens to do a check-in, which compounds the slowness.
  3. There are strange bugs, such as check-ins that don't stick.
  4. All searches are on venue name only, which is vulnerable to typos from fellow Foursquarers.
  5. Adding a venue is tedious and sometimes fails, so you have to key in all the info again.
  6. The granularity at which you can change your location is to the closest town or zip code, which could be miles off. Worse yet, the Foursquare people broke that function a week ago and haven't fixed it or responded to inquiries.
So my goals with 4sqNoGPS are:
  1. Lightweight website. Display all useful data with as little additional markup as possible. No Javascript.
  2. Because my phone does not have GPS, allow manual input of coordinates and make it easy to do on a phone without a full keyboard.
  3. Streamline the check-in process. Coordinate input should lead directly to a venue search around that point with one-click check-in after that.
  4. Add a venue by coordinates without entering a full address. (Foursquare API documentation refers to this as an "orphan", but I figure I could always fill in the address later when I'm back at the computer.)
Writing the app in Python to run on Google App Engine took about half a day. That included setting up my development environment on a different computer because I found out that App Engine is a bit behind time and only works with Python 2.5, not 2.7. That also included debugging oauthConsumer.py to find out why Foursquare was rejecting the OAuth handshake. I was surprised that Foursquare is actually more picky about OAuth parameters than Twitter.

There was also a bit of a trick to holding on to the request secret while the user visits the Foursquare website to allow the OAuth request. That's simple in a desktop application because you can keep that string in memory, but in a web application, the callback handler has to start from scratch. I borrowed a technique from one of the other OAuth libraries of using memcache with db backup to save the token and secret.

Once all those issues were settled, it was a snap to add the functionality and test it in the App Engine dev environment. There is more that I'd like to do -- for example, this app doesn't support shouts and doesn't show the user's badges yet -- but it already does what I need it for, so no hurry. I took it out on a few errands tonight as a test run. Among other venues, I went to the Scottish place. :) Yes, it is indeed faster than Foursquare Mobile. I hit a non-critical error when I checked in at Pathmark, so I'll have to make it a bit more tolerant of bad or missing data from Foursquare. I posted the code at Google Code but be forewarned that it's not production quality and it's probably useful only to me anyway. :)

python, yardwork, mcdonald's, foursquare, software development, twitter, oauth, pathmark

Previous post Next post
Up