今日と明日の天気予報 %s
天気:最高℃〜最低℃ 湿度 風速

%s℃〜%s℃ %s% %sm

%s℃〜%s℃ %s% %sm

'; extract(shortcode_atts(array('city' => 'Tokyo,jp'), $atts)); // [tokyo_weather city="Sapporo,jp"] $url = "http://api.openweathermap.org/data/2.5/forecast/daily/?units=metric&q=".$city."&units=metric&cnt=2"; $weather = json_decode(file_get_contents($url), true); $wea0=$weather['list'][0]['weather'][0]['icon']; $max0=intval($weather['list'][0]['temp']['max']+0.5); $min0=intval($weather['list'][0]['temp']['min']+0.5); $hum0=intval($weather['list'][0]['humidity']+0.5); $spd0=intval($weather['list'][0]['speed']+0.5); $wea1=$weather['list'][1]['weather'][0]['icon']; $max1=intval($weather['list'][1]['temp']['max']+0.5); $min1=intval($weather['list'][1]['temp']['min']+0.5); $hum1=intval($weather['list'][1]['humidity']+0.5); $spd1=intval($weather['list'][1]['speed']+0.5); return sprintf($weatherShow,$weather['city']['name'],$wea0,$max0,$min0,$hum0,$spd0,$wea1,$max1,$min1,$hum1,$spd1); } /* ショートコードを追加する */ add_shortcode('tokyo_weather', 'tokyo_weather_func'); ?>