wordpress获取新浪天气打造wordpress侧边栏天气(wordpress插件)
获取IP有两种方法,复杂的被我注释掉了,如果你想使用复杂的,去掉注释,再把简单的注释掉就可以了。 desc)) { $loc = $location->city; $full_loc = $location->province . $location->city . $location->district . $location->isp; } else { $loc = $location->desc; } return $loc;}$city = getIPLoc_sina("$SA_IP");
';?> $citycode = mb_convert_encoding($city,"gb2312","utf-8"); $doc = new DOMDocument();if (load("http://php.weather.sina.com.cn/xml.php?city">!@$doc->load("http://php.weather.sina.com.cn/xml.php?city=" . $citycode . "&password=DJOYnieT8234jlsK&day=0")) { echo "Get data failed!!n"; return;} $city = $doc->getElementsByTagName("city")->item(0)->nodeValue;$stat1 = $doc->getElementsByTagName("status1")->item(0)->nodeValue;$chy_shuoming = $doc->getElementsByTagName("chy_shuoming")->item(0)->nodeValue;$tmp1 = $doc->getElementsByTagName("temperature1")->item(0)->nodeValue;$tmp2 = $doc->getElementsByTagName("temperature2")->item(0)->nodeValue;$date = $doc->getElementsByTagName("savedate_weather")->item(0)->nodeValue;$pollution_l = $doc->getElementsByTagName("pollution_l")->item(0)->nodeValue;$gm_s = $doc->getElementsByTagName("gm_s")->item(0)->nodeValue; echo ' ' .$city .' / '.$date.' '. $tmp1 .'~'. $tmp2 .'℃'.$stat1 .' 空气质量:'.$pollution_l .' 穿衣建议:'. $chy_shuoming .' (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |