Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Google weather API // not proper UTF-8
gnoosny
post 11.05.2010, 19:40:35
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 11.05.2010

Ostrzeżenie: (0%)
-----


Witam
Jestem nowy w temacie, wlasciwie to PHP zaczalem poznawac wczoraj. Liznalem troche html.
Mam problem, chcialbym miec na stronie prognoze pogody oparta o API Google Weather.
Znalazlem kod
  1. <?
  2. $xml = simplexml_load_file('http://www.google.com/ig/api?weather=jedrzejow');
  3. $information = $xml->xpath("/xml_api_reply/weather/forecast_information");
  4. $current = $xml->xpath("/xml_api_reply/weather/current_conditions");
  5. $forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");
  6. ?>
  7. <html>
  8. <head>
  9. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  10. <title>Google Weather API</title>
  11. </head>
  12. <body>
  13. <h1><?= print $information[0]->city['data']; ?></h1>
  14. <h2>Today's weatherśćó</h2>
  15. <div class="weather">
  16. <img src="<?= 'http://www.google.com' . $current[0]->icon['data']?>" alt="weather"?>
  17. <span class="condition">
  18. <?= $current[0]->temp_f['data'] ?>&deg; F,
  19. <?= $current[0]->condition['data'] ?>
  20. </span>
  21. </div>
  22. <h2>Forecast</h2>
  23. <? foreach ($forecast_list as $forecast) : ?>
  24. <div class="weather">
  25. <img src="<?= 'http://www.google.com' . $forecast->icon['data']?>" alt="weather"?>
  26. <div><?= $forecast->day_of_week['data']; ?></div>
  27. <span class="condition">
  28. <?= $forecast->low['data'] ?>&deg; F - <?= $forecast->high['data'] ?>&deg; F,
  29. <?= $forecast->condition['data'] ?>
  30. </span>
  31. </div>
  32. <? endforeach ?>
  33. </body>
  34. </html>


Lecz gdy go odpalam to przegladarka wyswietla:


Cytat
Warning: simplexml_load_file() [function.simplexml-load-file]: http://www.google.com/ig/api?weather=jedrzejow:1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xF3 0x77 0x2C 0x20 in D:\wamp\www\pogoda.php on line 2

Warning: simplexml_load_file() [function.simplexml-load-file]: d="1" row="0" section="0" ><forecast_information><city data="Gmina J&#x119;drzej in D:\wamp\www\pogoda.php on line 2

Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in D:\wamp\www\pogoda.php on line 2

Fatal error: Call to a member function xpath() on a non-object in D:\wamp\www\pogoda.php on line 3


Dla takiej np. Dzakarty działa wiec problem lezy w kodowaniu :/ czy ktos mi moze wytlumaczyc badz nakierowac na wlasciwe rozwiazanie?
Druga sprawa czy to jest legalne?

Ps. chodzi mi tylko i wylacznie o pogode z googli, nie chce innej
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 12:39