wordpress获取新浪天气打造wordpress侧边栏天气(wordpress插件)

前端之家收集整理的这篇文章主要介绍了wordpress获取新浪天气打造wordpress侧边栏天气(wordpress插件)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

获取IP有两种方法,复杂的被我注释掉了,如果你想使用复杂的,去掉注释,再把简单的注释掉就可以了。

PHPcode3">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=" . $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 '

';?> 原文链接:https://www.f2er.com/wordpress/15323.html

猜你在找的wordpress相关文章