Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

OpenWeatherMapのAPIで無料で気象情報を取得する その4:複数都市の情報を出力

shuzo-kino.hateblo.jp
のシリーズ。

今回は複数都市の情報を出力する方法。
残念ながらHTML出力はうまくいていません。

http://api.openweathermap.org/data/2.5/group?id=524901,703448,2643743&mode=html&appid={{YOURAPPID}}
こんな塩梅で返ってきます。
個数があたまにあるので親切設計。

{"cnt":3,"list":[{"coord":{"lon":37.62,"lat":55.75},"sys":{"type":1,"id":7325,"message":0.0064,"country":"RU","sunrise":1519187979,"sunset":1519224449},"weather":[{"id":600,"main":"Snow","description":"light snow","icon":"13d"}],"main":{"temp":261.89,"pressure":1023,"humidity":85,"temp_min":261.15,"temp_max":263.15},"visibility":10000,"wind":{"speed":3,"deg":280},"clouds":{"all":0},"dt":1519207203,"id":524901,"name":"Moscow"},{"coord":{"lon":30.52,"lat":50.43},"sys":{"type":1,"id":7358,"message":0.0063,"country":"UA","sunrise":1519189053,"sunset":1519226774},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04d"}],"main":{"temp":272.81,"pressure":1023,"humidity":95,"temp_min":272.15,"temp_max":273.15},"visibility":10000,"wind":{"speed":3,"deg":100},"clouds":{"all":75},"dt":1519207203,"id":703448,"name":"Kiev"},{"coord":{"lon":-0.13,"lat":51.51},"sys":{"type":1,"id":5091,"message":0.015,"country":"GB","sunrise":1519196513,"sunset":1519234026},"weather":[{"id":721,"main":"Haze","description":"haze","icon":"50d"},{"id":701,"main":"Mist","description":"mist","icon":"50d"}],"main":{"temp":276.51,"pressure":1028,"humidity":75,"temp_min":275.15,"temp_max":278.15},"visibility":5000,"wind":{"speed":2.6,"deg":50},"clouds":{"all":0},"dt":1519207203,"id":2643743,"name":"London"}]