Ich habe festgestellt, dass der Fehler NICHT in der obigen Zeile auftritt, sondern in der darauffolgenden:
Code:
<?php /* Wetter ermitteln */
$location = $fieldsObjects['field_city']->data;
$xml = simplexml_load_file('http://www.google.com/ig/api?hl=de&weather='.$location);
$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");
?>
<h1><?= print $information[0]->city['data']; ?></h1>
<h2>Heutiges Wetter</h2>
<div class="weather">
<img src="<?= 'http://www.google.com' . $current[0]->icon['data']?>" alt="weather"?>
<span class="condition">
<?= $current[0]->temp_c['data'] ?>°C,
<?= $current[0]->condition['data'] ?>
</span>
</div>
<h2>Vorschau</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']-28 ?>°C bis <?= $forecast->high['data']-28 ?>°C,
<?= $forecast->condition['data'] ?>
</span>
</div>
<? endforeach ?>
<? /* Ende Wetter anzeigen */ ?>
Fatal error: Call to a member function xpath() on a non-object in /var/www/tz/components/com_sobi2/includes/inc/custom.weather.php on line 28
Zeile 28 ist die $information .....
Der Link funktioniert, wenn ich diesen direkt in die Adresszeile eingebe:
http://www.google.com/ig/api?hl=de&weather=Freiburg'
Ich habe nun die Zeile um Fehlerbehandlung erweitert:
$xml = simplexml_load_file('http://www.google.com/ig/api?hl=de&weather='.$location) or print "err could not load $xmlfilename";
und bekomme die Meldung:
err could not load
Warum finde ich die Daten nicht bei Aufruf aus php?
Suche verzweifelt nach einer Lösung.
Lesezeichen