我有一个 PHP 错误:
致命错误:在第 37 行的 /weather /classes/BxWeatherModule.php 中的非对象上调用成员函数 getElementsByTagName ()
这是代码:
function serviceWeatherIndexPage() {
include("geoipcity.inc");
include("geoipregionvars.php");
$ip = $_SERVER['REMOTE_ADDR'];
$weather_feed = "";
$pathr= BX_DOL_URL_ROOT;
$gi = geoip_open("../GeoLiteCity.dat",GEOIP_STANDARD);
$record = geoip_record_by_addr($gi,$ip);
geoip_close($gi);
$city = $record->city;
if ($city == "")
$city = "Sydney";
$url_post = "http://where.yahooapis.com/v1/places.q('".urlencode($city)."')?appid=foOF4CzV34EFIIW4gz1lx0Ze1em._w1An3QyivRalpXCK9sIXT5de810JWold3ApkdMdCrc-";
$weather_feed = file_get_contents($url_post);
$objDOM = new DOMDocument();
$objDOM->loadXML($weather_feed);
$woeid = $objDOM->getElementsByTagName("place")->item(0)->getElementsByTagName("woeid")->item(0)->nodeValue;
}