[php]
<?php
// Pour obtenir l'id user et pour activer ou désactiver : visit http://www.google.com/latitude/apps/badge
$googleLatitudeUser = '1234567890123456789';

// J'ai Zend_Framework et PEAR dans mon include_path.
require_once 'Zend/Http/Client.php';
require_once 'Zend/Json.php';
require_once 'Zend/Debug.php';
require_once 'Zend/Date.php';



$client = new Zend_Http_Client();
$client->setUri('http://www.google.com/latitude/apps/badge/api?user=-' . $googleLatitudeUser . '&type=json');
$client->request('GET');
/*
   * Le flux JSON adhère à la spécification GeoJSON 1.0. 
   * En plus du point identifié par la latitude et la longitude, 
   * les propriétés GeoJSON comprennent les id, accuracyInMeters, timeStamp, reverseGeocode, 
   * photoUrl, photWidth, photoHeight, placardUrl, placardWidth, placardHeight de l’utilisateur.
   *  
   * Pour les flux de partage du nom de la ville, la latitude et la longitude 
   * représentent le centre-ville et la précision est de 0.
   * */
$response = $client->request();
if ($response->isError()) {
    die($response->getStatus() . ": " . $response->getMessage());
}
$googleLatitude = Zend_Json::decode($response->getBody());

// le  0 c'est parce qu'on peu mettre user=[user1],[user2], ... dans la requête à l'api

$coordinates = $googleLatitude['features'][0]['geometry']['coordinates'];
$client->setUri('http://socialgraph.apis.google.com/otherme?q=moosh.be@gmail.com');
$client->request('GET');
$response = $client->request();
if ($response->isError()) {
    die($response->getStatus() . ": " . $response->getMessage());
}
$googleSocialgraph = Zend_Json::decode($response->getBody());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Test de google Latitude & google profil</title>
</head>
<body lang="fr">  
|  Il est à <?php
echo $googleLatitude['features']['0']['properties']['reverseGeocode']?> 

  
|  Latitude <?php
echo $coordinates[0];
?> 
|  Longitude <?php
echo $coordinates[1];
?> 
|  Précision <?php
echo $googleLatitude['features']['0']['properties']['accuracyInMeters']?> mètres 
|  TimeStamp <?php
echo $googleLatitude['features']['0']['properties']['timeStamp']?>
    =     <?php

Une utilisation toute simple de Zend_Date 

$date = new Zend_Date($googleLatitude['features']['0']['properties']['timeStamp'], Zend_Date::TIMESTAMP);
print $date;
?>
|  <br>Photo du user : 


<img
    src="<?php
echo $googleLatitude['features']['0']['properties']['photoUrl']?>"
    width="<?php
echo $googleLatitude['features']['0']['properties']['photoWidth']?>"
    height="<?php
echo $googleLatitude['features']['0']['properties']['photoHeight']?>" />

Phylactère du user :
<img
    src="<?php
echo $googleLatitude['features']['0']['properties']['placardUrl']?>"
    width="<?php
echo $googleLatitude['features']['0']['properties']['placardWidth']?>"
    height="<?php
echo $googleLatitude['features']['0']['properties']['placardHeight']?>" />
<br />
<a
    href="http://www.google.com/latitude/apps/badge/api?user=-<?php
echo $googleLatitudeUser;
?>&type=kml"
    style="color: #0000FF; text-align: left">Localisation KML</a>
|
<a
    href="http://maps.google.com/maps?f=q&amp;hl=fr&amp;ie=UTF8&amp;t=h&amp;z=14&amp;iwloc=A&amp;ll=<?php
echo $coordinates[1]?>,<?php
echo $coordinates[0]?>"
    style="color: #0000FF; text-align: left">Agrandir le plan</a>


<h2>Les cartes</h2>
La première c'est avec googlemap, la suivante directement via latitude
<h3>Satélite</h3>
<!-- Google Public Location Badge via GoogleMaps -->
<iframe width="500" height="350" frameborder="0" scrolling="no"
    marginheight="0" marginwidth="0"
    src="http://maps.google.com/maps?f=q&amp;hl=fr&amp;ie=UTF8&amp;t=k&amp;z=15&amp;ll=<?php
echo $coordinates[1]?>,<?php
echo $coordinates[0]?>&amp;output=embed"></iframe>
<!-- Google Public Location Badge -->
<iframe width="500" height="350" frameborder="0" scrolling="no"
    marginheight="0" marginwidth="0"
    src="http://www.google.com/latitude/apps/badge/api?user=-<?php
echo $googleLatitudeUser;
?>&amp;type=iframe&amp;maptype=satellite&amp;hl=fr&amp;z=15"></iframe>


<h3>Hybride</h3>
<!-- Google Public Location Badge via GoogleMaps -->
<iframe width="500" height="350" frameborder="0" scrolling="no"
    marginheight="0" marginwidth="0"
    src="http://maps.google.com/maps?f=q&amp;hl=fr&amp;ie=UTF8&amp;t=h&amp;z=15&amp;ll=<?php
echo $coordinates[1]?>,<?php
echo $coordinates[0]?>&amp;output=embed"></iframe>
<!-- Google Public Location Badge -->
<iframe width="500" height="350" frameborder="0" scrolling="no"
    marginheight="0" marginwidth="0"
    src="http://www.google.com/latitude/apps/badge/api?user=-<?php
echo $googleLatitudeUser;
?>&amp;type=iframe&amp;maptype=hybrid&amp;hl=fr&amp;z=15"></iframe>




<h3>Terrain</h3>
<!-- Google Public Location Badge via GoogleMaps -->
<iframe width="500" height="350" frameborder="0" scrolling="no"
    marginheight="0" marginwidth="0"
    src="http://maps.google.com/maps?f=q&amp;hl=fr&amp;ie=UTF8&amp;t=t&amp;z=15&amp;ll=<?php
echo $coordinates[1]?>,<?php
echo $coordinates[0]?>&amp;output=embed"></iframe>
<!-- Google Public Location Badge -->
<iframe width="500" height="350" frameborder="0" scrolling="no"
    marginheight="0" marginwidth="0"
    src="http://www.google.com/latitude/apps/badge/api?user=-<?php
echo $googleLatitudeUser;
?>&amp;type=iframe&amp;maptype=terrain&amp;hl=fr&amp;z=15"></iframe>



<h3>Routes</h3>
<!-- Google Public Location Badge via GoogleMaps -->
<iframe width="500" height="350" frameborder="0" scrolling="no"
    marginheight="0" marginwidth="0"
    src="http://maps.google.com/maps?f=q&amp;hl=fr&amp;ie=UTF8&amp;t=r&amp;z=15&amp;ll=<?php
echo $coordinates[1]?>,<?php
echo $coordinates[0]?>&amp;output=embed"></iframe>
<!-- Google Public Location Badge -->
<iframe width="500" height="350" frameborder="0" scrolling="no"
    marginheight="0" marginwidth="0"
    src="http://www.google.com/latitude/apps/badge/api?user=-<?php
echo $googleLatitudeUser;
?>&amp;type=iframe&amp;maptype=roadmap&amp;hl=fr&amp;z=15"></iframe>



<h2>Google Profile</h2>
<?php
foreach ($googleSocialgraph as $url => $data) {
    echo '<h3><a href="' . $url . '">' . $url . '</a></h3><dl>';
    foreach ($data['attributes'] as $attrName => $attrValue) {
        echo '<dt>
              ' . $attrName . '
             </dt>
             <dd>
              ' . var_export_intelligent($attrValue, 1) . '
              ' . (($attrName == 'photo') ? '<img src="' . $attrValue . '" />' : '') . '
              </dd>';
        ;
    }
    echo '</dl>';
    unset($data['attributes']);
    if (! empty($data))
        var_export($data);
}
?>
<h2>Infos brutes, retournées par l'api</h2>                                
<?php
Zend_Debug::dump($googleLatitude, 'info json', 1);
Zend_Debug::dump($googleSocialgraph, 'info social', 1);
?>
        
à voir : <a href="http://www.google.com/latitude/">Latitude</a>
&amp;
<a href="http://www.google.com/latitude/apps/badge">Latitude Badge</a>
</body>
</html>
<?php
function var_export_intelligent ($attrValue, $return)
{
    if (is_integer($attrValue)) {
        $val = $attrValue;
    } elseif (is_string($attrValue) && (substr($attrValue, 0, 7) == 'http://') && (in_array(substr($attrValue, - 3, 3), array('jpg' , 'gif' , 'png')))) {
        $val = '<img src="' . $attrValue . '" /> (' . $attrValue . ')';
    } elseif (is_string($attrValue) && (substr($attrValue, 0, 7) == 'http://')) {
        $val = '<a href="' . $attrValue . '">' . $attrValue . '</a>';
    } elseif (is_string($attrValue)) {
        $val = $attrValue;
    } else {
        $val = var_export($attrValue, 1);
    }
    if ($return) {
        return $val;
    } else {
        echo $val;
    }
}
?>