1、PHP天气API接口PHP天气API接口导读 中国天气网的API还每次还要先去判断ID,再获取天气信息,觉得有点麻烦,所以自己做了一个PHP一部搞定的。还有一个农历API。?phpheader(& 39;Access-Control-Allow-Origin: *& 39;);header(Content-Type:text中国天气网的API还每次还要先去判断ID,再获取天气信息,觉得有点麻烦,所以自己做了一个PHP一部搞定的。还有一个农历API。view sourceprint?01.code=1)43.return false;44.45.$data = $ip-data-city;46.
2、return $data; 47.48. 49.function getWeather($cityId)50.51.$url=52.$weather=file_get_contents($url);53.return $weather; 54.55.function $web)56.$arr=array();57.foreach($web as $k=$w)58.if(is_object($w) $arr$k=$w); /判断类型是不是object59.else $arr$k=$w;60.61.return $arr;62.63.$city = getCity(getIP();64.$city
3、 = str_split($city,strlen($city)-3);65.$city =$city0;66.$cityUrl = 67.$web=file_get_contents($cityUrl);68.$arr=$web);69.$weatherInfo = getWeather($arr$city);70.echo(weather();71.echo($weatherInfo);72.echo();73. 74.?城市源码 view sourceprint?01.02.03.04.05.无标题文档06.07.08. 09.10.11.12. 13.14. 15. 16.17.18.
4、19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.var weatherInfo;43.var lunar;44.var date = new Date();45.var g=晴:0 0px,多云:0 -40px,暴雪:0 -480px,大雪-暴雪:0 -480px,暴雨:0 -360px,大雨-暴雨:0 -360px,暴雨-大暴雨:0 -360px,大暴雨-特大暴雨:0 -360px,大暴雪:0 -480px,飑:0 -880px,大雪:0 -440px,中雪-大雪:0 -440px,大雨:0 -3
5、20px,中雨-大雨:0 -320px,浮层:0 -920px,雷阵雨:0 -160px,雷阵雨并伴有冰雹:0 -200px,霾:0 -920px,轻雾:0 -840px,雾:0 -840px,冰雹:0 -680px,沙尘暴:0 -760px,强沙尘暴:0 -760px,特大暴雪:0 -520px,小雪:0 -600px,小雨:0 -240px,扬沙:0 -720px,浮尘:0 -920px,龙卷风:0 -800px,弱高吹雪:0 -600px,阴:0 -80px,雨夹雪:0 -400px,冻雨:0 -960px,阵雪:0 -560px,阵雨:0 -120px,中雪:0 -640px,小雪-中
6、雪:0 -640px,小雨-中雨:0 -280px,中雨:0 -280px;46.$(document).ready(function() 47.$(#weekday).html(date.getDate();48.$.getScript(getWeather.php);49.$.getScript(lunar.php);50.);51.var weather = function(data)52.weatherInfo = data;53.$(.cityWrap .name).html(data.weatherinfo.city);54.$(.cityInfo .name).html(dat
7、a.weatherinfo.weather1);55.$(.cityWrap .info).html(data.weatherinfo.city_en);56.$(.cityInfo .info).html(data.weatherinfo.st1+);57.$(.weapic).css(background-position,gdata.weatherinfo.weather1).show();58.59.var lunar = function(data)60.lunar = data;61.var month = data.month;62.var day = data.day;63.$(#lunarday).html(农历+month+day);64.$(#dateday).html(date.getFullYear()+.
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1