Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

wikinear.com, OAuth and Fire Eagle

I’m pleased to announce wikinear.com. It’s a simple site that does just one thing: show you a list of the five Wikipedia pages that are geographically closest to your current location. It’s designed (or not-designed) to be used mainly from mobile phones.

You’ll need a Fire Eagle invitation code to use the site. I’ve got four spare; the first four comments to ask for one can have them my invites are all accounted for. If you don’t have a Fire Eagle account you’ll have to make do with this screenshot instead.

The idea for the site came from living in Oxford for a year. The city is full of beautiful old historic buildings (many of them colleges), but very few of them are labelled or signposted. With wikinear.com and a GPS hooked up to Fire Eagle, I can pull out my phone and see a list of the closest points of interest, plotted on a handy map.

Under the hood the site combines a number of interesting technologies: OAuth, Fire Eagle, GeoNames and the new Google Static Maps API.

OAuth

OAuth was originally designed to solve a problem with OpenID: in an authentication protocol based on browser redirects, how do you authenticate a desktop or command-line application? As it turned out, the solution to that problem solved a bunch of other problems that are unrelated to OpenID, so OAuth now exists as very much its own thing. In essence, it lets users delegate permission to perform actions on their behalf, without having to hand their regular authentication credentials (e.g. username and password) over to a third-party piece of software.

If you’ve ever used a Flickr application that sends you back to Flickr to ask permission to view your private photos you’ll understand what OAuth does straight away. Before OAuth, sites had to invent their own solutions to this problem—complete with smart security measures, their own UI flow and libraries for developers wishing to access their protected APIs. OAuth provides a ready-made solution, complete with tested libraries in a bunch of languages.

If you want to securely expose your user’s private data via an API, OAuth is a no-brainer. I expect to see a lot more of it over the next year.

Fire Eagle

Launched at ETech a few weeks ago, Fire Eagle is a service with enormous potential. You can watch Tom Coates explain it in ten minutes in this video from the conference, but the short version is that Fire Eagle acts as a location broker. It consists of two key OAuth-protected APIs: one for setting the geographical location of a user, and another for retrieving that location.

This leads to a neat separation of concerns. On the one hand are the applications that attempt to figure out your location—GPS receivers, WiFi maps, mobile phones that triangulate nearby cell towers, or even sites that know where you are because you told them (Dopplr and Upcoming, for example, or the Fire Eagle site itself). On the other hand are the applications that do something useful with your location—from restaurant review sites, traffic alert services, friend finders and ARGs down to trivial applications like wikinear.com.

As a developer, this is really exciting. I can build location-based services without having to solve the much bigger problem of figuring out where my users are. Even better, wikinear.com becomes incrementally more useful every time someone builds a new tool for passing location information to Fire Eagle, without me having to do anything at all.

Obviously privacy is a huge concern when dealing with this kind of data. That’s where the Fire Eagle application itself comes in: it provides a simple suite of tools for users to manage the applications that can access their location. Applications can be permitted to access different levels of accuracy or disabled entirely, and there’s a “Hide” button for disabling all applications at once.

Disclaimer: I worked on an early prototype of Fire Eagle as my last project at Yahoo! before leaving in January 2007, but the product that has launched has changed enormously and is entirely the work of the current Fire Eagle team. wikinear.com is inspired by part of that early prototype.

Wikipedia and GeoNames

Wikipedia has a thriving community of geo-hackers, mainly focused around the Maps, Geographical coordinates and Wikipedia-World wiki projects. Many Wikipedia pages (Brighton, for example) have their co-ordinates in the top-right, added using a bewildering array of macros and markup extensions. You can browse through the huge collection of geotagged pages using this KML-powered Google Maps tool—zoom in and wait a few seconds to load in more markers.

The wonderful GeoNames (also used on djangopeople.net) includes an API for querying Wikipedia by location, based on 610,000 articles extracted from a Wikipedia data dump. This was a huge relief when I found it, as “order by distance from X” is actually pretty tricky to do efficiently; I’ve used expanding bounding box searches in the past but I’d love to hear about more effective solutions.

Google Static Maps

A long-term criticism of the Google Maps API is that it requires JavaScript to display anything at all—once you’ve committed to using it, you’re going to have trouble implementing unobtrusive scripting (although you can work around the problem to some extent). Yahoo! Maps has long been better in this regard, but their map image API is a bit of a pain to use—you have to do an initial call to get back the URL to an image embedded in an XML file, then extract that URL and send it to the browser.

Launched last month, Google’s Static Maps API is a big improvement. As with Google Charts, you need only construct a URL to the image to have it dynamically generated on the fly. You can also specify markers, and optionally omit the initial latitude/longitude/zoom to indicate that you want a best fit for the markers you are displaying. There’s even a flag for a “mobile optimised” image which I’m using for wikinear.com.

Mixing it all together

Excluding templates, the entire application comes in at less than 200 lines of code and took around two hours to build. The only persistence is a couple of cookies for storing Fire Eagle tokens; Django’s database layer isn’t even configured (and user locations aren’t logged anywhere, which is great from a privacy point of view). I suppose it’s a classic mashup—Fire Eagle + OAuth + Wikipedia + GeoNames + Google Static Maps = wikinear.com. Despite its simplicity (or maybe because if it), I think it’s a neat demonstration of the kind of applications Fire Eagle enables.

This is wikinear.com, OAuth and Fire Eagle by Simon Willison, posted on 22nd March 2008.

Tagged , , , , , ,

View blog reactions

Next: jQuery style chaining with the Django ORM

Previous: Django People: OpenID and microformats

31 comments

  1. I'd like a FireEagle invite please... now I can get back to reading your article!

    trovster - 22nd March 2008 14:53 - #

  2. I want my invite too please :)

    patcito - 22nd March 2008 15:01 - #

  3. Brilliant idea, Simon!

    I wouldn't mind an invite too, if you've any left.

    David Logie - 22nd March 2008 15:03 - #

  4. Send one to me also, please!
    evh293 at freemail dot hu
    thx :)

    Hangya - 22nd March 2008 15:05 - #

  5. OK, all invites are accounted for... trying to track down contact details for trovster, patcito and David Logie.

    Simon Willison - 22nd March 2008 15:07 - #

  6. nice one. It actually serves as a good demo for all these technologies, including Django itself.
    Also the two-column layout works perfectly with the iPhone's zoom functionality.
    Bookmarked :)

    Cyril Doussin - 22nd March 2008 15:11 - #

  7. patcito and David: got an e-mail address?

    Simon Willison - 22nd March 2008 15:13 - #

  8. As soon as I posted my comment I realised there was no field for email address and my website is woefully bad... so it's my nick @gmail.com

    trovster - 22nd March 2008 15:15 - #

  9. Awesome. Now we need equivalents for things like nearby bars / cafés / wifi hotspots / public transport and stuff like that!

    Some of you in the meantime might be wondering how to get your location into Fire Eagle. Navizon announced that all of their applications were going to be Fire Eagle enabled yesterday (I think).

    The link to turn on that feature is here:
    http://www.navizon.com/FireEagleInvitation.asp

    Then you have to login to the member section and turn it on before set appear visible to 'on' on your client. It also works on iPhones if they've been cracked.

    Or you can use Dopplr of course, or Zonetag.

    Tom Coates - 22nd March 2008 15:57 - #

  10. Very nice.

    nanek - 22nd March 2008 16:01 - #

  11. "I've used expanding bounding box searches in the past but I'd love to hear about more effective solutions." - PledgeBank finds nearby pledges with a database function and some simple maths, see location_find_nearby in https://secure.mysociety.org/cvstrac/fileview?f=my society/pb/db/schema.sql . As FixMyStreet is GB only and has eastings/northing instead of lat/lon, it's even simpler, see problem_find_nearby in https://secure.mysociety.org/cvstrac/fileview?f=my society/bci/db/schema.sql

    Matthew - 22nd March 2008 16:50 - #

  12. This is freakin' awesome!! What a cool app!

    - Sean

    Sean Ammirati - 22nd March 2008 18:08 - #

  13. Simon, this is great stuff. Any chance we could see the code? I'd love to see how you're doing OAuth.

    Michael - 22nd March 2008 18:27 - #

  14. Michael: I basically pasted code over from the Fire Eagle docs (which appear to be hidden behind an authentication wall; would be nice if you could just link to them). I've posted the whole views.py file from wikinear.com to Django snippets which shows how pretty much everything works.

    Simon Willison - 22nd March 2008 19:20 - #

  15. Michael/Simon: my Python API binding for Fire Eagle (which is the official one, as shipped by Fire Eagle) is on GitHub if you want to look at the source of that, too.

    Steve Marshall - 22nd March 2008 22:53 - #

  16. Very cool.

    Why not use the Gmaps Geocoder so those of us without Fire Eagle accounts can try this with any place we specify?

    Alex - 22nd March 2008 23:44 - #

  17. Sounds very exciting, I look forward to testing it out once I get my FireEagle invite.

    Well done!

    Newsfeed - 23rd March 2008 11:51 - #

  18. I want my invite code please:)
    send one to me:
    suntrace at gmail dot com
    thx

    Alex Lv - 24th March 2008 08:19 - #

  19. For mobile users, you might consider linking to wapedia.mobi instead of Wikipedia itself. I assume (but don't know for sure) that they mirror the same content as the main site.

    Brian Cantoni - 2nd April 2008 02:25 - #

  20. Simon, this app is really amazing! I absolutely loved it. Thank you very much for sharing!

    web pixy - 2nd April 2008 14:04 - #

  21. Please send one to me too.
    Thanks.
    http://www.lrn.ir

    Bayrami - 3rd April 2008 11:35 - #

  22. Hi.
    Thanks , it was very nice.

    Morovati - 3rd April 2008 11:36 - #

  23. Cool app.!
    Unfortunately there is no fireeagle app. yet for SMS.
    How do you propose to update our location from a mobile phone in the meantime?

    Stefan - 5th April 2008 19:23 - #

  24. a FireEagle invite would be most generous :)

    Air Jordans - 7th April 2008 00:48 - #

  25. I would like to have an invitation please.

    hectorabanal at gmail.com

    thank :)

    hectorabanal - 10th April 2008 09:16 - #

  26. Kewl concept. Can I get an invite?

    Erik - 17th April 2008 22:52 - #

  27. Awesome app. The only thing that could be improved is the signing in process (for it just takes too long), but I believe that's a FireEagle problem (?).

    Everytime I try to use wikinear, I have to authorize it again to use my F.E. data. With APIs like Flickr, this only has to be done once.

    wikinear blog post

    B10m - 2nd May 2008 08:29 - #

  28. Hey Simon.
    Got a spare invite?
    Thanks.

    cruster - 7th May 2008 16:57 - #

  29. Anyone have an invite? erica at helloerica.com

    Erica - 12th May 2008 23:54 - #

  30. Hi Simon, I assume you've seen it, but haven't spotted a reference. The Ordnance Survey's OpenSpace project is out of closed-alpha and is now into open-ish beta: http://openspace.ordnancesurvey.co.uk/openspace/

    Phil Wilson - 9th June 2008 00:54 - #

  31. Hi Simon,

    I'd love a invite to Fire Eagle, if you have one left ofcourse. You can send it to sidney dot dekoning at gmail dot com

    Thanks!

    Sidney

    Sidney de Koning - 23rd June 2008 12:35 - #

Sign in with OpenID

Auto-HTML: Line breaks are preserved; URLs will be converted in to links.

Manual XHTML: Enter your own, valid XHTML. Allowed tags are a, p, blockquote, ul, ol, li, dl, dt, dd, em, strong, dfn, code, q, samp, kbd, var, cite, abbr, acronym, sub, sup, br, pre

A django site