PHP天气API接口Word格式.docx

上传人:b****6 文档编号:19272179 上传时间:2023-01-04 格式:DOCX 页数:19 大小:20.89KB
下载 相关 举报
PHP天气API接口Word格式.docx_第1页
第1页 / 共19页
PHP天气API接口Word格式.docx_第2页
第2页 / 共19页
PHP天气API接口Word格式.docx_第3页
第3页 / 共19页
PHP天气API接口Word格式.docx_第4页
第4页 / 共19页
PHP天气API接口Word格式.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

PHP天气API接口Word格式.docx

《PHP天气API接口Word格式.docx》由会员分享,可在线阅读,更多相关《PHP天气API接口Word格式.docx(19页珍藏版)》请在冰豆网上搜索。

PHP天气API接口Word格式.docx

)){

 

return$realip;

}

*获取IP地理位置

*淘宝IP接口

*@Return:

array

functiongetCity($ip)

$url="

$ip=file_get_contents($url));

if((string)$ip->

code=='

1'

){

returnfalse;

}

$data=$ip->

data->

city;

return$data;

functiongetWeather($cityId)

$weather=file_get_contents($url));

return$weather;

function$web){

$arr=array();

foreach($webas$k=>

$w){

if(is_object($w))$arr[$k]=$w);

//判断类型是不是object

else$arr[$k]=$w;

return$arr;

$city=getCity(getIP());

$city=str_split($city,strlen($city)-3);

$city=$city[0];

$cityUrl="

$web=file_get_contents($cityUrl));

$arr=$web);

$weatherInfo=getWeather($arr[$city]);

echo('

weather('

echo($weatherInfo));

echo("

)"

>

城市源码 

!

DOCTYPEhtmlPUBLIC"

-//W3C//DTDXHTML1.0Transitional//EN"

"

http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

htmlxmlns="

//www.w3.org/1999/xhtml"

head>

metahttp-equiv="

Content-Type"

content="

text/html;

charset=utf-8"

/>

title>

无标题文档<

/title>

linkrel="

stylesheet"

href="

main.css"

type="

text/css"

/head>

body>

divclass="

top"

<

top_content"

divid="

calendarArea"

spanclass="

datepic"

fontid="

weekday"

/font>

/span>

ul>

li>

spanid="

lunarday"

/li>

dateday"

/ul>

/div>

topWeatherArea"

<

ulclass="

cityWrap"

<

liclass="

name"

<

info"

weapic"

cityInfo"

scripttype="

text/javascript"

src="

../../js/jquery.js"

/script>

../../js/loadjs.js"

varweatherInfo;

varlunar;

vardate=newDate();

varg={"

晴"

:

"

00px"

"

多云"

0-40px"

暴雪"

0-480px"

大雪-暴雪"

暴雨"

0-360px"

大雨-暴雨"

暴雨-大暴雨"

大暴雨-特大暴雨"

大暴雪"

飑"

0-880px"

大雪"

0-440px"

中雪-大雪"

大雨"

0-320px"

中雨-大雨"

浮层"

0-920px"

雷阵雨"

0-160px"

雷阵雨并伴有冰雹"

0-200px"

霾"

轻雾"

0-840px"

雾"

冰雹"

0-680px"

沙尘暴"

0-760px"

强沙尘暴"

特大暴雪"

0-520px"

小雪"

0-600px"

小雨"

0-240px"

扬沙"

0-720px"

浮尘"

龙卷风"

0-800px"

弱高吹雪"

阴"

0-80px"

雨夹雪"

0-400px"

冻雨"

0-960px"

阵雪"

0-560px"

阵雨"

0-120px"

中雪"

0-640px"

小雪-中雪"

小雨-中雨"

0-280px"

中雨"

};

$(document).ready(function(){

$("

#weekday"

).html(date.getDate());

$.getScript("

getWeather.php"

lunar.php"

});

varweather=function(data){

weatherInfo=data;

.cityWrap.name"

).html(data.weatherinfo.city);

.cityInfo.name"

).html(data.weatherinfo.weather1);

.cityWrap.info"

).html(data.weatherinfo.city_en);

.cityInfo.info"

).html(data.weatherinfo.st1+"

℃"

.weapic"

).css("

background-position"

g[data.weatherinfo.weather1]).show();

varlunar=function(data){

lunar=data;

varmonth=data.month;

varday=data.day;

#lunarday"

).html("

农历"

+month+day);

#dateday"

).html(date.getFullYear()+"

."

+(date.getMonth()+1)+"

+date.getDate()+"

&

nbsp;

+getWeek(date.getDay()));

vargetWeek=function(day){

switch(day){

case0:

return"

周一"

;

case1:

周二"

case2:

周三"

case3:

周四"

case4:

周五"

case5:

周六"

case6:

周日"

/body>

/html>

@charset"

utf-8"

*{

padding:

0;

margin:

border:

none;

text-decoration:

list-style:

overflow:

hidden;

input,button,select,textarea{

outline:

textarea{

font-size:

13px;

resize:

body{

background:

#F2F2F2url(topcenterno-repeat;

.top{

width:

100%;

height:

65px;

.top_content{

960px;

0auto;

#calendarArea{

155px;

float:

left;

cursor:

pointer;

padding-left:

15px;

#calendarArea:

hover,#topWeatherArea:

hover{

url(topright;

.datepic{

background-image:

url(

background-repeat:

no-repeat;

31px;

32px;

text-align:

center;

16px;

font-weight:

bold;

line-height:

display:

block;

15px10px00;

#weekday{

position:

relative;

top:

4px;

color:

#fff;

#calendarAreaul{

40px;

padding-top:

3px;

#calendarArea#lunarday{

#calendarArea#dateday{

14px;

#topWeatherArea{

165px;

10px;

.cityWrap{

margin-top:

5px;

.weapic{

15px5px05px;

none;

.cityInfo{

.name{

17px;

.info{

14px;

classLunar{

public$MIN_YEAR=1891;

public$MAX_YEAR=2100;

public$lunarInfo=array(array(0,2,9,21936),array(6,1,30,9656),array(0,2,17,9584),array(0,2,6,21168),array(5,1,26,43344),array(0,2,13,59728),array(0,2,2,27296),array(3,1,22,44368),array(0,2,10,43856),array(8,1,30,19304),array(0,2,19,19168),array(0,2,8,42352),array(5,1,29,21096),array(0,2,16,53856),array(0,2,4,55632),array(4,1,25,27304),array(0,2,13,22176),array(0,2,2,39632),array(2,1,22,19176),array(0,2,10,19168),array(6,1,30,42200),array(0,2,18,42192),array(0,2,6,53840),array(5,1,26,54568),array(0,2,14,46400),array(0,2,3,54944),array(2,1,23,38608),array(0,2,11,38320),array(7,2,1,18872),array(0,2,20,18800),array(0,2,8,42160),array(5,1,28,45656),array(0,2,16,27216),array(0,2,5,27968),array(4,1,24,44456),array(0,2,13,11104),array(0,2,2,38256),array(2,1,23,18808),array(0,2,10,18800),array(6,1,30,25776),array(0,2,17,54432),array(0,2,6,59984),array(5,1,26,27976),array(0,2,14,23248),array(0,2,4,11104),array(3,1,24,37744),array(0,2,11,37600),array(7,1,31,51560),array(0,2,19,51536),array(0,2,8,54432),array(6,1,27,55888),array(0,2,15,46416),array(0,2,5,22176),array(4,1,25,43736),array(0,2,13,9680),array(0,2,2,37584),array(2,1,22,51544),array(0,2,10,43344),array(7,1,29,46248),array(0,2,17,27808),array(0,2,6,46416),array(5,1,27,21928),array(0,2,14,19872),array(0,2,3,42416),array(3,1,24,21176),array(0,2,12,21168),array(8,1,31,43344),array(0,2,18,59728),array(0,2,8,27296),array(6,1,28,44368),array(0,2,15,43856),array(0,2,5,19296),array(4,1,25,42352),array(0,2,13,42352),array(0,2,2,21088),array(3,1,21,59696),array(0,2,9,55632),array(7,1,30,23208),array(0,2,17,22176),array(0,2,6,38608),array(5,1,27,19176),array(0,2,15,19152),array(0,2,3,42192),array(4,1,23,53864),array(0,2,11,53840),array(8,1,31,54568),array(0,2,18,46400),array(0,2,7,46752),array(6,1,28,38608),array(0,2,16,38320),array(0,2,5,18864),array(4,1,25,42168),array(0,2,13,42160),array(10,2,2,45656),array(0,2,20,27216),array(0,2,9,27968),array(6,1,29,44448),array(0,2,17,43872),array(0,2,6,38256),array(5,1,27,18808),array(0,2,15,18800),array(0,2,4,25776),array(3,1,23,27216),array(0,2,10,59984),array(8,1,31,27432),array(0,2,19,23232),array(0,2,7,43872),array(5,1,28,37736),array(0,2,16,37600),array(0,2,5,51552),array(4,1,24,54440),array(0,2,12,54432),array(0,2,1,55888),array(2,1,22,23208),array(0,2,9,22176),array(7,1,29,43736),array(0,2,18,9680),array(0,2,7,37584),array(5,1,26,51544),array(0,2,14,43344),array(0,2,3,46240),array(4,1,23,46416),array(0,2,10,44368),array(9,1,31,21928),array(0,2,19,19360),array(0,2,8,42416),array(6,1,28,21176),array(0,2,16,21168),array(0,2,5,43312),array(4,1,25,29864),array(0,2,12,27296),array(0,2,1,44368),array(2,1,22,19880),array(0,2,10,19296),array(6,1,29,42352),array(0,2,17,42208),array(0,2,6,53856),array(5,1,26,59696),array(0,2,13,54576),array(0,2,3,23200),array(3,1,23,27472),array(0,2,11,38608),array(11,1,31,19176),array(0,2,19,19152),array(0,2,8,42192),array(6,1,28,53848),array(0,2,15,53840),array(0,2,4,54560),array(5,1,24,55968),array(0,2,12,46496),array(0,2,1,22224),array(2,1,22,19160),array(0,2,10,18864),array(7,1,30,42168),array(0,2,17,42160),array(0,2,6,43600),array(5,1,26,46376),array(0,2,14,27936),array(0,2,2,44448),array(3,1,23,21936),array(0,2,11,37744),array(8,2,1,18808),array(0,2,19,18800),array(0,2,8,25776),array(6,1,28,27216),array(0,2,15,59984),array(0,2,4,27424),array(4,1,24,43872),array(0,2,12,43744),array(0,2,2,37600),array(3,1,21,51568),array(0,2,9,51552),array(7,1,29,54440),array(0,2,17,54432),array(0,2,5,55888)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1