Morton Fox (mortonfox) wrote,
Morton Fox

Mobile webapp in one day - 4sqNoGPS

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: 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 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. :)
Tags: foursquare, mcdonald's, oauth, pathmark, python, software development, twitter, yardwork

  • Virtual Conventions

    The COVID-19 pandemic has forced a number of furry conventions to cancel this year due to state and local emergency regulations and also out of…

  • FA United 2019

    Last weekend was FA United 2019 in Northern Virginia. That was my fourth and last furry convention for the year. It'll be hard to cut one convention…

  • Metro Gathering 2019

    The last few years, Metro Gathering was in October and had a Halloween theme. This year though, the geocaching mega event is in September and has a…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded