Google Weather API への接続時にエラーが発生しました
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Google_weather extends CI_Controller {
function index()
{
$xml = simplexml_load_file('http://www.google.com/ig/api?weather=california');
$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");
$pic = $current[0]->icon['data'];
if($pic == "/ig/images/weather/chance_of_snow.gif") { $changeImage = base_url()."images/web/chance-of-snow.png"; }
else if($pic == "/ig/images/weather/flurries.gif") { $changeImage = base_url()."images/web/flurries.png"; }
else if($pic == "/ig/images/weather/snow.gif") { $changeImage = base_url()."images/web/snow.png"; }
else if($pic == "/ig/images/weather/sleet.gif") { $changeImage = base_url()."images/web/sleet.png"; }
else if($pic == "/ig/images/weather/chance_of_rain.gif") { $changeImage = base_url()."images/web/chance-of-rain.png"; }
else if($pic == "/ig/images/weather/chance_of_storm.gif") { $changeImage = base_url()."images/web/chance-of-storm.png"; }
$data = array('weather' => $changeImage);
$this->load->view('weather_view.php',$data);
}
}
}
どういうわけか接続しますが、時々エラーを返します:致命的なエラー:/Applications/XAMPP/xamppfiles/htdocs/testing/application/controllers/google_weather.phpの行xxの非オブジェクトでメンバー関数xpath()を呼び出します
どうすればこれを解決できますか? 高度なthx!