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
<? $xml = simplexml_load_file('http://www.google.com/ig/api?weather=jedrzejow'); $information = $xml->xpath("/xml_api_reply/weather/forecast_information"); $current = $xml->xpath("/xml_api_reply/weather/current_conditions"); $forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> <title>Google Weather API</title> </head> <body> <h2>Today's weatherśćó</h2> <div class="weather"> <img src="<?= 'http://www.google.com' . $current[0]->icon['data']?>" alt="weather"?> <span class="condition"> <?= $current[0]->temp_f['data'] ?>° F, <?= $current[0]->condition['data'] ?> </span> </div> <h2>Forecast</h2> <? foreach ($forecast_list as $forecast) : ?> <div class="weather"> <img src="<?= 'http://www.google.com' . $forecast->icon['data']?>" alt="weather"?> <div><?= $forecast->day_of_week['data']; ?></div> <span class="condition"> <?= $forecast->low['data'] ?>° F - <?= $forecast->high['data'] ?>° F, <?= $forecast->condition['data'] ?> </span> </div> <? endforeach ?> </body> </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ę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
Warning: simplexml_load_file() [function.simplexml-load-file]: d="1" row="0" section="0" ><forecast_information><city data="Gmina Ję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