似乎从 Wunderground 读取“条件”JSON 输出与准备从“警报”输出非常不同。下面是我的代码的简化版本。
$json_stringalert = file_get_contents("http://api.wunderground.com/api/myKey/alerts/q/MO/Kansas_City.json");
$parsed_jsonalert = json_decode($json_stringalert);
$description = $parsed_jsonalert->{'alerts'}->{'description'};
echo "${description}
回显是空白的,并且没有错误。URL 的输出部分如下所示;
{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"alerts": 1
}
}
,"query_zone": "037",
"alerts": [
{
"type": "FIR",
"description": "Fire Weather Warning",
"date": "10:27 am CST on March 2, 2017",
"date_epoch": "1488472020",
"expires": "6:00 PM CST on March 02, 2017",
"expires_epoch": "1488499200",
"tz_short":"CST",
"tz_long":"America/Chicago",
"message": "\u000A...Red flag warning in effect until 6 PM CST this evening for\u000Abreezy northwest winds and low relative humidity values for fire \u000Aweather zones 020, 021, 025, 028, 029, 030, 037, 038, 043, 044, \u000A045, 053, 054, 057, 060, 102, 103, 104, and 105...\u000A\u000AThe National Weather Service in Kansas City/Pleasant Hill has\u000Aissued a red flag warning, which is in effect until 6 PM CST this\u000Aevening. \u000A\u000A* Affected area...fire weather zones 025, 057, 060, 102, 103, \u000A 104, and 105.Fire weather zones 020, 021, 028, 029, 030, 037, \u000A 038, 043, 044, 045, 053, and 054. \u000A\u000A* Wind...sustained northwest winds of 20 mph with higher gusts are\u000A expected this afternoon. \u000A\u000A* Humidity...relative humidity values will fall into the low to\u000A middle 20 percent range. \u000A\u000A* Impacts...any fires that develop will likely spread rapidly. \u000A Outdoor burning is not recommended.\u000A\u000APrecautionary/preparedness actions...\u000A\u000AA red flag warning means that critical fire weather conditions\u000Aare either occurring now, or will shortly. A combination of\u000Astrong winds, low relative humidity, and warm temperatures can\u000Acontribute to extreme fire behavior.\u000A\u000A\u000A\u000ACramer\u000A\u000A\u000A",
"phenomena": "FW",
"significance": "W", ...
and more below.
有人可以帮我编写代码以使用“描述”和其他输出吗?