Google Static Maps in a feed: Referer problem

I've successfully embedded Google Static Maps in an RSS feed that I'm working on, and it displays great in standalone feed readers. Unfortunately, if someone tries to subscribe to my feed using a web-based reader/aggregator (such as Google Reader), my images don't show up. Presumably, the referer of the aggregator website is sent to maps.google.com, which rejects the request as not matching my API key.

Is there some trick I can use to make this work? Here are the options I can imagine:

  • Have the feed pull images from geohash.info, which in turn downloads the real image file and caches it
  • Again, have the images come from geohash.info, but this time have the page act as a non-caching proxy for maps.google.com (but setting a far-future expiration)
  • Trick the browser into sending geohash.info as a referer
  • Serve a different version of the feed to aggregator bots (based on their referer), using their API key (I don't know how I'd get that)
  • Have the image URLs point to a page at geohash.info that grabs the API key for the referer, and redirects to the maps.google.com URL using that API key (again, probably not an option)

Update a few hours later: That last approach worked! I found a way to look up the API key for any site, so now I can embed key-less static maps, like this:

Example static map

Responses: 6 so far

  1. Mark says:

    Hi,

    I love your idea for using a redirect to make static maps work in rss aggregators. I wrote my own php redirect script to do this, however my static maps still don't display in google reader.

    How exactly did you do your redirect?

    Any help you could offer would be much appreciated.

  2. Mark says:

    Oh, taking a closer look at your post I see that you 'look up the API key for any site'. How do you do this?

  3. Tim McCormack says:

    @Mark: Here is the API key URL for NewsGator: http://www.google.com/maps/api_signup?url=http%3A%2F%2Fwww.newsgator.com%2F (For example.)

    For a while I had a PHP script that would automatically grab that page and parse it whenever I saw a new referer, but Google soon put a stop to it. :-(

    I was able to contact someone at Google about the issue, and she said they were looking into removing the referer check... but that was a while ago, and I haven't seen any changes.

    For now I just serve up an alternate image to people who have unknown referers. The image explains the referer problem.

  4. Mark says:

    Ah, I see.

    So, I could get the API keys for a few common aggregators and do the redirect trick for those?

  5. Tim McCormack says:

    @Mark: My current database of keys should get you started.

  6. Mark says:

    Thanks so much, Tim. I'll give it a go.