46 lines
1.9 KiB
PHP
46 lines
1.9 KiB
PHP
<?php
|
|
|
|
require('class/GoogleWeather.class.php');
|
|
$present_weather = null;
|
|
//ça récupère un truc du style : http://www.google.com/ig/api?weather=paris&hl=fr
|
|
if ( !empty($ville) ) {
|
|
$google_weather = new GoogleWeatherAPI($ville, 'fr');
|
|
|
|
if ($google_weather->isFound()) {
|
|
$city = $google_weather->getCity();
|
|
$currentTemp = $google_weather->getCurrent();
|
|
$forecastTemp = $google_weather->getForecast();
|
|
|
|
$present_weather = 'Actuellement : ' . $currentTemp['temp_c'] . '°C - ' . $currentTemp['condition'];
|
|
$future_weather = [];
|
|
foreach ($forecastTemp as $temp) {
|
|
$future_weather[] = $temp['day_of_week'] . ' : ' . $temp['low'] . '°C | ' . $temp['high'] . '°C - ' . $temp['condition'];
|
|
}
|
|
|
|
if (strpos(strtolower($present_weather), "soleil") !== false) { ?>
|
|
<link rel="stylesheet" type="text/css" href="modules/weather/css/soleil.css">
|
|
<?php
|
|
}
|
|
if (strpos(strtolower($present_weather), "nuage") !== false) { ?>
|
|
<link rel="stylesheet" type="text/css" href="modules/weather/css/nuage.css">
|
|
<?php
|
|
}
|
|
if (strpos(strtolower($present_weather), "peu nuageux") !== false) { ?>
|
|
<link rel="stylesheet" type="text/css" href="modules/weather/css/peunuage.css">
|
|
<?php
|
|
}
|
|
if ((strpos(strtolower($present_weather), "pluie") !== false) || (strpos(strtolower($present_weather), "averse") !== false)) { ?>
|
|
<link rel="stylesheet" type="text/css" href="modules/weather/css/pluie.css">
|
|
<?php
|
|
}
|
|
if (strpos(strtolower($present_weather), "neige") !== false) { ?>
|
|
<link rel="stylesheet" type="text/css" href="modules/weather/css/neige.css">
|
|
<?php
|
|
}
|
|
} else {
|
|
$present_weather = 'Ville non trouvé : ' . $ville;
|
|
}
|
|
} else {
|
|
$present_weather = 'Ville non renseignée';
|
|
}
|