1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  | /**
 * Permet de récupérer des informations à partir du nom d'une ville via l'API Yahoo! PlaceFinder
 *
 * @param string $town Nom de la ville
 * @return array Informations à propos de la ville (http://developer.yahoo.com/geo/placefinder/guide/responses.html#elements)
 * 
 * @author   Progi1984
 */
function Yahoo_GetCountry($town){
  $town	= urlencode($town);
  $appid = 'VOTRE_APPID'; // Obtenez votre AppID : http://developer.apps.yahoo.com/wsregapp/
  $url = 'http://where.yahooapis.com/geocode?q='.$town.'&locale=fr_FR&appid='.$appid.'&flags=P';
  $hCurl = curl_init();
  curl_setopt($hCurl, CURLOPT_URL, $url);
  curl_setopt($hCurl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($hCurl, CURLOPT_CONNECTTIMEOUT, 5);
  $hData = curl_exec($hCurl);
  curl_close($hCurl);
  $hData = unserialize($hData);
  return $hData['ResultSet']['Result'][0];
}
  |