圖文天氣查詢
效果

<?php
$msg=$this->message['content'];
$id=$this->message['from'];
$msgid=$this->message['msgid'];
$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';
$w=file_get_contents($url);
$weather=json_decode($w,TRUE);
$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_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);