Monday, June 1, 2009

The Ever Elusive Geocoded Search in Desktop Twitter Clients

twitter

So I said to myself, “Hell, if I’m going to write a blog, why not start out with a bang and jump right into some decent content and skip the usual “Hello World” introduction small talk stuff?” So, what the hay…here goes nothing….

Like many of the recent Twitter legions signing up by the busloads as of late, I too am a recent convert. And if there’s one thing I’m good at, it’s diving into something head first, feet flailing and praying to god I don’t belly flop. So, I have been reading voraciously blog post after blog post about all of the wonders and glories the Twitterverse has to offer and test-driving close to a dozen different desktop Twitter clients, all while tweeting regularly to my modest following and keeping tabs on my Twitter stream.

Well, one of my early discoveries was the beauty and usefulness from a networking point of view of being able to utilize Twitter’s own search functionality to find other people in my geographical area that share my same interests. For example, in the search field provided by Twitter on my home page, I can type “wine near:93463 within:15mi” and it would search for any tweets containing the word “wine” sent by someone who was within 15 miles of the zipcode 93463, which happens to be my own town of Solvang, CA. This is perhaps my favorite, and in my opinion one of the most useful, features of Twitter’s search functionality. Whether you are looking to broaden your local social circle or you are a small business looking to do some targeted searches for new followers, you too have probably fallen in love with this search function just as I have.

Of course, as with most loves, this one was not without some heartache. As quickly as I was enamored with my new found Twitter social tool, my confidence in it plummeted when I discovered that not a single desktop Twitter client was capable of performing these types of searches. I tried close to a dozen of them in vain, typing in multiple variations of the “near:” and “within:” search operators, always left frustrated and feeling like maybe, just maybe the next desktop client I try will be The ONE. But it never came. Not Tweetdeck, nor Tweetie, nor Twitterific, Lounge, nor even my current favorite, Nambu. The thing is, I couldn’t bring myself to use just the Twitter website for my daily Twitter needs. After all, it didn’t have groups, or built in URL shortening, or a fancy shmancy looking Adobe Air user interface. I mean, why drive a Pinto when you have a Bentley at your disposal, right?

Well, I’m not one to give up easily, so I searched and searched and I finally found the answer I was looking for, hidden in some technical developer jargon on the Twitter API Wiki pages. It was there in black and white, the ultimate letdown (or so I thought) – “Note that you cannot use the near operator via the API to geocode arbitrary locations”. Ugh. Basically it is saying that my Holy Grail is imposibble. That there were restrictions to their software API that did not allow a desktop client to utilize the near: search function. But, surrounding that hideous phrase was a workaround – not nearly as simple and elegant as the near: and within: functions, but just as effective. Enter stage left, the geocode: search operator.

What the Twitter API Wiki says is the following:

geocode: Optional. Returns tweets by users located within a given radius of the given latitude/longitude, where the user’s location is taken from their Twitter profile. The parameter value is specified by “latitide,longitude,radius“, where radius units must be specified as either “mi” (miles) or “km” (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly. Example: http://search.twitter.com/search.atom?geocode=40.757929%2C-73.985506%2C25km

So, essentially, instead of using the near: & within: search operators, you could replace them with this geocode: search function. In the search field of your desktop Twitter client, you would then type “geocode:latitude,longitude,radius(followed by mi or km)“ The above example from the API Wiki would be rendered in your desktop client’s search window as follows:

geocode:40.757929,-73.985506,25km.

Note that there are no spaces after the colon or the commas. The search will fail to execute if you include spaces.

By now, you are probably saying, well that’s fine and dandy, but how the heck do I find the geocoding for my location? Fear not, that’s where a site such as geocoder.us comes in. Just enter your address into their search field and it will return both the latitude and longitude in three different formats. You want the first of the three, which is the decimal version before the little degree symbol – ” ° “. Now just plug those two numbers into the above format and you’re all set! Remember to use Latitude before Longitude and DO include any ” – ” signs before a reading if the geocoding service indicates one.

If you want to be more specific with your geocode searches, you can add a word or phrase you want to search for BEFORE the geocode: function, such as:

wine geocode:40.757929,-73.985506,25km

being sure to put a space between “wine” and “geocode”.

Well, that’s it! If you found this first blog post of mine helpful, please be sure to let me know in the comments area. Or let me know on Twitter: @TheMystik. In the meantime, happy geocoding!

No comments:

Post a Comment