天气接口

## 天气接口 参考地址: https://openweathermap.org/guide https://openweathermap.org/current #### 1. 使用openWeather API接口 ![image.png](https://cos.easydoc.net/21942958/files/kev2zo92.png) - api_key: ```a9e95b29c785688b2623e05c2568e27e``` - 天气指标 只获取 (1)室外温度: main.temp - 273.15 (减 273.15 转换成摄氏度) (2)室外湿度: main.humidity % (3)天气描述: weather[0].description (4)天气描述icon: 根据weather[0].icon的值,对应的icon url如下: ``` # 01d or 01n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/01d.png # 02d or 02n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/02d.png # 03d or 03n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/03d.png # 04d or 04n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/04d.png # 09d or 09n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/09d.png # 10d or 10n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/10d.png # 11d or 11n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/11d.png # 13d or 13n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/13d.png # 50d or 50n https://storage.googleapis.com/my-first-action-project-96da6.appspot.com/weathers/50d.png ``` #### 2. 根据城市名称获取当前天气 http://api.openweathermap.org/data/2.5/weather?q=Sydney,AU&appid={{api_key}} ``` { "coord": { "lon": 151.21, "lat": -33.87 }, "weather": [ { "id": 803, "main": "Clouds", "description": "broken clouds", "icon": "04n" } ], "base": "stations", "main": { "temp": 285.81, "feels_like": 280.97, "temp_min": 284.82, "temp_max": 287.15, "pressure": 1027, "humidity": 87 }, "visibility": 9000, "wind": { "speed": 7.2, "deg": 170 }, "clouds": { "all": 75 }, "dt": 1599639491, "sys": { "type": 1, "id": 9600, "country": "AU", "sunrise": 1599595378, "sunset": 1599637347 }, "timezone": 36000, "id": 2147714, "name": "Sydney", "cod": 200 } ``` ![image.png](https://cos.easydoc.net/21942958/files/kfhwd79x.png) ![image.png](https://cos.easydoc.net/21942958/files/kfhwdohe.png) #### 3. 通过 位置坐标 获取天气 http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}