Monday, June 30, 2008

SMS - Twitter - Google Maps Geocoding Craziness

It works! I must admit it's a little surprising because my programming talents could fit into a thimble. But it works! Check it out at http://redneck-haiku.f-sw.com/.

There is alot of streamlining and rewriting to do. A number of features came to mind after the core code was in place, so it will mean a busy few days. Of course, having it rain every day while you are on vacation makes it easier to code and not do other things, outside.

Sunday, June 29, 2008

Hacking Twitter

I've recently create a Twitter account, which in and of itself, is fairly pointless. However, it does allow you to post to the web via SMS. So if you are like me and work for a cheap-ass company that doesn't pay for email phones, it works well because you can post via text-messaging.

This gave me an interesting idea. If you could scrape that info using a web-app of some description you might be able to do something interesting with it. Having recently acquired a Microsoft Streets and Trips 2006 with GPS for a stupidly low price, I have been playing around with Latidudinal and Longitudinal coordinates, the Google Maps API, and Javascript/AJAX. I occured to me that if I posted coordinates to my Twitter account, maybe I could scrape those coords off the page and generate a Google Map from them.

It turns out the HttpRequests in AJAX do not like to play outside their own domain (ie. you can't pull data from twitter.com from a page on google pages). So to get around this javascript issue, I used PHP. It's really simple, actually, and here is a rough outline of how it works:

  1. PHP creates a SimpleXML object that pulls my last twitter entry (in xml format) into a variable.
  2. The PHP script writes a cookie with the coordinates pulled from twitter.
  3. PHP forward to another page that uses Javascript (the Google API language of choice).
  4. The javascript page reads the cookie and parses out the coordinates.
  5. The javascript uses the coordinates as the centre of a Google Map.

I will post more info later. Still in the debugging / thinking of features stage. I am sure there are a grillion or so real programmers who will shoot holes through my methods. I don't care. As a non-programmer this seems like a pretty slick set up to me.