reference:
https://blog.csdn.net/xuw_xy/article/details/89407607
https://blog.csdn.net/oAlevel/article/details/86976348
//-----------------------------------------------------------------------
Use knew Weather API
Registration https://www.seniverse.com
Receive free development of key https://www.seniverse.com/products?iid=new
Free user rights
What data the user can call free
370 major cities in China
- Live weather, weather phenomena including text, code and temperature data 3
- The weather forecast for the next three days, including the day and weather phenomena text and codes, text and codes evening weather phenomenon, the same day the maximum and minimum temperatures, wind direction and wind speed
- 6 basic classes of living index, including clothing, UV intensity, car washing, travel, cold, movement index
//-------------------------------------------------
Use arduinojson slice parsing tool to do https://arduinojson.org/v5/assistant/
Is an example, in the following as an example of living index
const size_t capacity = JSON_ARRAY_SIZE(1) + JSON_OBJECT_SIZE(1) + 6*JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) + 2*JSON_OBJECT_SIZE(6) + 350; DynamicJsonBuffer jsonBuffer(capacity); const char* json = "{\"results\":[{\"location\":{\"id\":\"WTMKQ069CCJ7\",\"name\":\"杭州\",\"country\":\"CN\",\"path\":\"杭州,杭州,浙江,中国\",\"timezone\":\"Asia/Shanghai\",\"timezone_offset\":\"+08:00\"},\"suggestion\":{\"car_washing\":{\"brief\":\"不宜\",\"details\":\"\"},\"dressing\":{\"brief\":\"热\",\"details\":\"\"},\"flu\":{\"brief\":\"易发\",\"details\":\"\"},\"sport\":{\"brief\":\"较不宜\",\"details\":\"\"},\"travel\":{\"brief\":\"较不宜\",\"details\":\"\"},\"uv\":{\"brief\":\"弱\",\"details\":\"\"}},\"last_update\":\"2019-06-30T13:49:49+08:00\"}]}"; JsonObject& root = jsonBuffer.parseObject(json); JsonObject& results_0 = root["results"][0]; JsonObject& results_0_location = results_0["location"]; const char* results_0_location_id = results_0_location["id"]; // "WTMKQ069CCJ7" const char* results_0_location_name = results_0_location["name"]; // "杭州" const char* results_0_location_country = results_0_location["country"]; // "CN" const char* results_0_location_path = results_0_location["path"]; // "杭州,杭州,浙江,中国" const char* results_0_location_timezone = results_0_location["timezone"]; // "Asia/Shanghai" const char* results_0_location_timezone_offset = results_0_location["timezone_offset"]; // "+08:00" JsonObject& results_0_suggestion = results_0["suggestion"]; const char* results_0_suggestion_car_washing_brief = results_0_suggestion["car_washing"]["brief"]; // "不宜" const char* results_0_suggestion_car_washing_details = results_0_suggestion["car_washing"]["details"]; // "" const char* results_0_suggestion_dressing_brief = results_0_suggestion["dressing"]["brief"]; // "热" const char* results_0_suggestion_dressing_details = results_0_suggestion["dressing"]["details"]; // "" const char* results_0_suggestion_flu_brief = results_0_suggestion["flu"]["brief"]; // "易发" const char* results_0_suggestion_flu_details = results_0_suggestion["flu"]["details"]; // "" const char* results_0_suggestion_sport_brief = results_0_suggestion["sport"]["brief"]; // "较不宜" const char* results_0_suggestion_sport_details = results_0_suggestion["sport"]["details"]; // "" const char* results_0_suggestion_travel_brief = results_0_suggestion["travel"]["brief"]; // "较不宜" const char* results_0_suggestion_travel_details = results_0_suggestion["travel"]["details"]; // "" const char* results_0_suggestion_uv_brief = results_0_suggestion["uv"]["brief"]; // "弱" const char* results_0_suggestion_uv_details = results_0_suggestion["uv"]["details"]; // "" const char* results_0_last_update = results_0["last_update"]; // "2019-06-30T13:49:49+08:00"
//-------------------------------------------------
Weather API requests using the last three days
https://api.seniverse.com/v3/weather/daily.json?key=youkey&location=hangzhou&language=zh-Hans&unit=c&start=0&days=4
{"results":[{"location":{"id":"WTMKQ069CCJ7","name":"杭州","country":"CN","path":"杭州,杭州,浙江,中国","timezone":"Asia/Shanghai","timezone_offset":"+08:00"},"daily":[{"date":"2019-
06-30","text_day":"暴雨","code_day":"16","text_night":"中雨","code_night":"14","high":"29","low":"25","precip":"","wind_direction":"北","wind_direction_degree":"0","wind_speed":"15","wind_scale":"3"},{"date":"2019-07-01","text_day":"中雨","code_day":"14","text_night":"中雨","code_night":"14","high":"27","low":"24","precip":"","no sustained wind":"wind_direction","wind_direction_degree":"","wind_speed":"10","wind_scale":"2"},{"date":"2019-07-02","text_day":"小雨","code_day":"13",""rain":"text_night,"code_night":"13","high":"24","low":"22","precip":"","wind_direction":"东","wind_direction_degree":"90","wind_speed":"15","wind_scale":"3"}],"last_update":"2019-06-30T11:00:00+08:00"}]}
Requests the current weather temperature
https://api.thinkpage.cn/v3/weather/now.json?key=youkey&location=hangzhou&language=zh-Hans&unit=c
{"results":[{"location":{"id":"WTMKQ069CCJ7","name":"杭州","country":"CN","path":"杭州,杭州,浙江,中国","timezone":"Asia/Shanghai","timezone_offset":"+08:00"},"now":{"text":"多云","c
ode":"4","temperature":"28"},"last_update":"2019-06-30T16:20:00+08:00"}]}
Request living index
https://api.seniverse.com/v3/life/suggestion.json?key=youkey&location=shanghai&language=zh-Hans
{"results":[{"location":{"id":"WTW3SJ5ZBJUY","name":"上海","country":"CN","path":"上海,上海,中国","timezone":"Asia/Shanghai","timezone_offset":"+08:00"},"suggestion":{"car_washing":{"brief":"不宜","details":""},"dressing":{"brief":"舒适","details":""},"flu":{"brief":"the Details","Easier hair":""},"sport":{"brief":"较不宜","details":""},"travel":{"brief":"一般","details":""},"uv":{"brief":"最弱","details":""}},"last_update":"2019-06-30T15:20:10+08:00"}]}
emmm, the question now put is whether one can request all of the data, not feeling