Monday, February 16, 2009

Getting Location From Google Latitude

Location based applications would sometimes need to track locations continuously to plot some paths or trigger certain actions. If Google had exposed Google Latitude with APIs, it would have become so much more easier to build applications on it. But alas, it does not yet have any APIs. Probably they are waiting to see if it gathers momentum greater than that Dodgeball did.

Here is a small observation on how to still do it, though in a smaller scale. It is not very elegant, and I lack deeper knowledge of Google APIs to dig deeper. But here it is nevertheless:

Trace the requests that your browser makes when you view Google Latitude through iGoogle. Here's what you see:

Request:
URL=http://.ig.ig.gmodules.com/gadgets/makeRequest
Host=.ig.ig.gmodules.com
Content-Length=515
Pragma=no-cache
Cache-Control=no-cache
POSTDATA=url=http%3A%2F%2Fwww.google.com%2Fglm%2Fmmap%2Fig%3Frandom%3D0.%26t%3Dfs&httpMethod=GET&headers=&postData=&authz=oauth&st=c%3Dig%26e%3D&contentType=JSON&numEntries=3&getSummaries=false&signOwner=true&signViewer=true&gadget=http%3A%2F%2Fwww.google.com%2Fig%2Fmodules%2Ffv.xml&container=ig&bypassSpecCache=0&oauthState=&OAUTH_SERVICE_NAME=google


Response (Uncompressed):
throw 1; <>
{
"http://www.google.com/glm/mmap/ig?random=0.&t=fs": {
"headers":{},
"body":"[0,[,
[
[,[,\"some_number\",3,1,1,,0]\n,\"...@gmail.com\",\"Name\",,12914044,77600009,\"some_number\",150,[\"\",\"Location Text\"]\n,\"\",\"some_number\",,\"/photos/private/photo_id\",\"180906\",\"some_number\",0]\n,
[,[,\"some_number\",3,1,1,,0]\n,\"...@gmail.com\",\"Name\",,12889499,77601873,\"some_number\",573,[\"\",\"Location Text\"]\n,\"\",\"some_number\",,\"/photos/private/photo_id\",\"261704650\",\"some_number\",1]\n,

some other stuff...}
}


The response JSON has the gmail IDs (marked in green above) and latitude-longitude combination (marked in red above) for you and all your friends.

So log on to iGoogle through a proxy that logs all responses, pass it through a parser to extract the information out. Better still, create a firefox plugin that does it.

2 comments:

Tanmay said...

Self comment...
Two interesting articles on this:

The Cellphone, Navigating Our Lives from The New York Times
and
Google Is Tracking Your Every Move from Esquire

Anonymous said...

basic API now available