微信開發小功能
<?php
$msg
=
$this
->message[
'content'
];
//文本消息內容
$id
=
$this
->message[
'from'
];
//用戶ID
$msgid
=
$this
->message[
'msgid'
];
//消息ID
$time
=
$this
->message[
'time'
];
//消息發送時間
return
$this
->respText(
$msg
);
$city
=
str_replace
(
"天氣"
,
""
,
$msg
);
if
(
empty
(
$city
)){
$city
=
'江夏'
;
}
$url
=
'http://api.map.baidu.com/telematics/v3/weather?location='
.
$city
.
'&output=json&ak=rMyLMFj0NLj6TbKqul7m6Bf6'
;
//$json=ihttp_get($url);
$w
=
file_get_contents
(
$url
);
/* if($json['code']!=200){
return $this->respText('網絡連接失敗,請重試');
} */
$weather
=json_decode(
$w
,TRUE);
//$error1 = $weather[error];
$now
=
$weather
[
date
];
//今天日期
$c
=
$weather
[results][0][currentCity];
//城市
$wall
=
$weather
[results][0][weather_data];
$n
=
count
(
$wall
);
//第一天
$today
=
$wall
[0][
date
];
$today_dayPictureUrl
=
$wall
[0][dayPictureUrl];
//白天圖片
$today_nightPictureUrl
=
$wall
[0][nightPictureUrl];
//夜晚圖片
$today_wind
=
$wall
[0][wind];
//風力
$today_weather
=
$wall
[0][weather];
//氣候
$today_temperature
=
$wall
[0][temperature];
//氣溫
//次日天氣
$tomorrow
=
$wall
[1][
date
];
$tomorrow_dayPictureUrl
=
$wall
[1][dayPictureUrl];
//白天圖片
$tomorrow_nightPictureUrl
=
$wall
[1][nightPictureUrl];
//夜晚圖片
$tomorrow_wind
=
$wall
[1][wind];
//風力
$tomorrow_weather
=
$wall
[1][weather];
//氣候
$tomorrow_temperature
=
$wall
[1][temperature];
//氣溫
//第三天
$afterTomorrow
=
$wall
[2][
date
];
$afterTomorrow_dayPictureUrl
=
$wall
[2][dayPictureUrl];
//白天圖片
$afterTomorrow_nightPictureUrl
=
$wall
[2][nightPictureUrl];
//夜晚圖片
$afterTomorrow_wind
=
$wall
[2][wind];
//風力
$afterTomorrow_weather
=
$wall
[2][weather];
//氣候
$afterTomorrow_temperature
=
$wall
[2][temperature];
//氣溫
//第四天
$fourDay
=
$wall
[3][
date
];
$fourDay_dayPictureUrl
=
$wall
[3][dayPictureUrl];
//白天圖片
$fourDay_nightPictureUrl
=
$wall
[3][nightPictureUrl];
//夜晚圖片
$fourDay_wind
=
$wall
[3][wind];
//風力
$fourDay_weather
=
$wall
[3][weather];
//氣候
$fourDay_temperature
=
$wall
[3][temperature];
//氣溫
$news
[] =
array
(
'title'
=>
"$c $now"
,
'description'
=>
''
,
'picurl'
=>
''
,
'url'
=>
'http://zy62.com'
);
$news
[] =
array
(
'title'
=>
"$today $today_weather $today_wind $today_temperature"
,
'description'
=>
''
,
'picurl'
=>
$today_dayPictureUrl
,
'url'
=>
'http://zy62.com'
);
$news
[] =
array
(
'title'
=>
"$tomorrow $tomorrow_weather $tomorrow_wind $tomorrow_temperature"
,
'description'
=>
''
,
'picurl'
=>
$tomorrow_dayPictureUrl
,
'url'
=>
'http://zy62.com'
);
$news
[] =
array
(
'title'
=>
"$afterTomorrow $afterTomorrow_weather $afterTomorrow_wind $afterTomorrow_temperature"
,
'description'
=>
''
,
'picurl'
=>
$afterTomorrow_dayPictureUrl
,
'url'
=>
'http://zy62.com'
);
$news
[] =
array
(
'title'
=>
"$fourDay $fourDay_weather $fourDay_wind $fourDay_temperature"
,
'description'
=>
''
,
'picurl'
=>
$fourDay_dayPictureUrl
,
'url'
=>
'http://zy62.com'
);
return
$this
->respNews(
$news
);
return
$this
->respText(
$today_weather
);
if
(
$rs
){
return
$this
->respText(
$error
);
}
else
{
return
$this
->respText(
'獲取失敗'
);
}
$error
=
$rs
[
'error'
];
return
$this
->respText(
$rs
);
推薦文章
2025-01-18
2024-11-28
2024-11-09
2024-10-25
2024-06-25
2024-01-04
2023-11-06
2023-10-30
2023-10-13
2023-10-10
穩定
產品高可用性高并發貼心
項目群及時溝通專業
產品經理1v1支持快速
MVP模式小步快跑承諾
我們選擇聲譽堅持
10年專注高端品質開發