Hub on Google Apis
71Simple way to use google latitude api
Google Latitude is one of the latest api's to be launched by google .
And there is no doubt that this product has been made keeping in
mind the mobile internet user's in mind .This thread is about how
you can use the google latitude api to create killer apps . You can
also use your google latitude account to continiusoly track your location
and create an history of his location data to track abnormal behavior .
There are two ways through which you can use the google latitude api
1) Google Latitude Api through Oauth verification
2) Google Latitude through badge api .
In this thread I will be showing you how you can retrieve the
location using google latitude badge api .
You need to have a google latitude account created or enabled
if you already have an google account . Next Step goto
https://www.google.co.in/latitude/b/0/apps
In this page enable Google Public Location Badge to show the best
city level location .Note down your userid in the iframe block .
Once you are done with that you are ready to get started with the
coding to get the users's location . The php code is as given below
<?php
//Replace the YOURUSERID in the url below with your Badge userid .
$url="http://www.google.com/latitude/apps/badge/api?user=YOURUSERID&type=json";
// We get the content
$content = file_get_contents( $url );
// We convert the JSON to an object
$json = json_decode( $content );
$coord = $json->features[0]->geometry->coordinates;
// this will give you the coordinates of the user
echo $coord ;
$timeStamp = $json->features[0]->properties->timeStamp;
// timestamp of the last update
echo $timestamp ;
// If you want to retrieve the longitude & latitude separately $latitude=$coord[0];
$longitude=$coord[1];
echo "Your current coordinates Latitude :".$latitude." Longitude".$longitude ;
?>
You can either use this data to mashup with other api's like Google Maps api
or Google Weather Api to create killer apps .
For mashups ,howto and source code on google latitude api you can visit
my blog page
http://googlelatiude.blogspot.com/2011/03/google-latitude-mashup-with-google-maps.html
Thanks ,
Vaishakh






