kombinował ktoś z parsowaniem jsona z
http://api.wunderground.com/api/XXXXAPI ... owice.json ?
w odpowiedzi leci:
{
"response": {
"version":"0.1",
"termsofService":"
http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
}
, "current_observation": {
"image": {
"url":"
http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"
http://www.wunderground.com"
},
"display_location": {
"full":"Katowice, Poland",
"city":"Katowice",
"state":"SL",
"state_name":"Poland",
"country":"PL",
"country_iso3166":"PL",
"zip":"00000",
"magic":"267",
"wmo":"12560",
"latitude":"50.25999832",
"longitude":"19.02000046",
"elevation":"278.9"
},
"observation_location": {
"full":"Katowice, ",
"city":"Katowice",
"state":"",
"country":"PL",
"country_iso3166":"PL",
"latitude":"50.28",
"longitude":"19.01",
"elevation":"919 ft"
},
"estimated": {
},
"station_id":"IKATOWIC68",
"observation_time":"Last Updated on January 31, 2:45 PM CET",
"observation_time_rfc822":"Thu, 31 Jan 2019 14:45:18 +0100",
"observation_epoch":"1548942318",
"local_time_rfc822":"Thu, 31 Jan 2019 14:45:25 +0100",
"local_epoch":"1548942325",
"local_tz_short":"CET",
"local_tz_long":"Europe/Warsaw",
"local_tz_offset":"+0100",
"weather":"Scattered Clouds",
"temperature_string":"38.1 F (3.4 C)",
"temp_f":38.1,
"temp_c":3.4,
"relative_humidity":"51%",
"wind_string":"From the South at 1.1 MPH Gusting to 2.5 MPH",
"wind_dir":"South",
"wind_degrees":189,
"wind_mph":1.1,
"wind_gust_mph":"2.5",
"wind_kph":1.8,
"wind_gust_kph":"4.0",
"pressure_mb":"1001",
"pressure_in":"29.56",
"pressure_trend":"0",
"dewpoint_string":"22 F (-6 C)",
"dewpoint_f":22,
"dewpoint_c":-6,
"heat_index_string":"NA",
"heat_index_f":"NA",
"heat_index_c":"NA",
"windchill_string":"38 F (3 C)",
"windchill_f":"38",
"windchill_c":"3",
"feelslike_string":"38 F (3 C)",
"feelslike_f":"38",
"feelslike_c":"3",
"visibility_mi":"4.3",
"visibility_km":"7.0",
"solarradiation":"142",
"UV":"1.0","precip_1hr_string":"0.07 in ( 2 mm)",
"precip_1hr_in":"0.07",
"precip_1hr_metric":" 2",
"precip_today_string":"0.06 in (2 mm)",
"precip_today_in":"0.06",
"precip_today_metric":"2",
"icon":"partlycloudy",
"icon_url":"
http://icons.wxug.com/i/c/k/partlycloudy.gif",
"forecast_url":"
http://www.wunderground.com/global/stations/12560.html",
"history_url":"
http://www.wunderground.com/weatherstat ... IKATOWIC68",
"ob_url":"
http://www.wunderground.com/cgi-bin/fin ... ,19.005272",
"nowcast":""
}
}
jak w Twig wyciąnąc wartosci z atrybutu np
"weather":"Scattered Clouds",
"temp_c":3.4,
Zeby można było zrobić warunek. Oczywiście bardziej koszernie niz regexp
