You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GoogleMeteo.php 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. require('class/GoogleWeather.class.php');
  3. $present_weather = null;
  4. //ça récupère un truc du style : http://www.google.com/ig/api?weather=paris&hl=fr
  5. if ( !empty($ville) ) {
  6. $google_weather = new GoogleWeatherAPI($ville, 'fr');
  7. if ($google_weather->isFound()) {
  8. $city = $google_weather->getCity();
  9. $currentTemp = $google_weather->getCurrent();
  10. $forecastTemp = $google_weather->getForecast();
  11. $present_weather = 'Actuellement : ' . $currentTemp['temp_c'] . '°C - ' . $currentTemp['condition'];
  12. $future_weather = [];
  13. foreach ($forecastTemp as $temp) {
  14. $future_weather[] = $temp['day_of_week'] . ' : ' . $temp['low'] . '°C | ' . $temp['high'] . '°C - ' . $temp['condition'];
  15. }
  16. if (strpos(strtolower($present_weather), "soleil") !== false) { ?>
  17. <link rel="stylesheet" type="text/css" href="modules/weather/css/soleil.css">
  18. <?php
  19. }
  20. if (strpos(strtolower($present_weather), "nuage") !== false) { ?>
  21. <link rel="stylesheet" type="text/css" href="modules/weather/css/nuage.css">
  22. <?php
  23. }
  24. if (strpos(strtolower($present_weather), "peu nuageux") !== false) { ?>
  25. <link rel="stylesheet" type="text/css" href="modules/weather/css/peunuage.css">
  26. <?php
  27. }
  28. if ((strpos(strtolower($present_weather), "pluie") !== false) || (strpos(strtolower($present_weather), "averse") !== false)) { ?>
  29. <link rel="stylesheet" type="text/css" href="modules/weather/css/pluie.css">
  30. <?php
  31. }
  32. if (strpos(strtolower($present_weather), "neige") !== false) { ?>
  33. <link rel="stylesheet" type="text/css" href="modules/weather/css/neige.css">
  34. <?php
  35. }
  36. } else {
  37. $present_weather = 'Ville non trouvé : ' . $ville;
  38. }
  39. } else {
  40. $present_weather = 'Ville non renseignée';
  41. }