{"id":3298,"date":"2021-09-12T20:09:35","date_gmt":"2021-09-12T11:09:35","guid":{"rendered":"https:\/\/auto-worker.com\/blog\/?p=3298"},"modified":"2021-09-12T20:13:49","modified_gmt":"2021-09-12T11:13:49","slug":"post-3298","status":"publish","type":"post","link":"https:\/\/auto-worker.com\/blog\/?p=3298","title":{"rendered":"\u30102021\u5e74\u7248\u3011GAS\u3067\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u624b\u9806(Open Weather Map\u7121\u6599API)"},"content":{"rendered":"<p>Google Apps Script(GAS)\u3067\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3057\u307e\u3059\u3002<\/p>\n<p>\u30cd\u30c3\u30c8\u3067\u306fLivedoor\u5929\u6c17API\u3092\u4f7f\u3063\u305f\u89e3\u8aac\u8a18\u4e8b\u304c\u591a\u3044\u3067\u3059\u304c\u30012020\u5e74\u306b\u30b5\u30fc\u30d3\u30b9\u7d42\u4e86\u3057\u305f\u305f\u3081\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<p>2021\u5e74\u3067\u3082\u4f7f\u7528\u53ef\u80fd\u306a\u300cOpen Weather Map\u300d\u306e\u7121\u6599API\u3092\u4f7f\u3063\u305f\u5929\u6c17\u4e88\u5831\u53d6\u5f97\u306eGAS\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h2>Livedoor\u5929\u6c17\u306f2020\u5e74\u30b5\u30fc\u30d3\u30b9\u7d42\u4e86<\/h2>\n<p>Google Apps Script(GAS)\u3067\u3088\u304f\u4f5c\u6210\u3055\u308c\u308b\u30a2\u30d7\u30ea\u306b\u5929\u6c17\u4e88\u5831\u3092\u901a\u77e5\u3059\u308b\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u300cGAS\u3000\u5929\u6c17\u300d\u3068\u691c\u7d22\u3059\u308b\u3068\u3001Livedoor\u5929\u6c17\u306eAPI\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u5929\u6c17\u3092\u30e1\u30fc\u30eb\u3057\u305f\u308a\u3001LINE\u901a\u77e5\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306e\u89e3\u8aac\u8a18\u4e8b\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>2020\u5e74\u4ee5\u524d\u306b\u767a\u884c\u3055\u308c\u305fGoogle Apps Script\u306e\u5165\u9580\u66f8\u7c4d\u3067\u3082\u3001\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3068\u3057\u3066Livedoor\u5929\u6c17API\u304c\u7528\u3044\u3089\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001Livedoor\u5929\u6c17\u306f2020\u5e747\u6708\u306b\u30b5\u30fc\u30d3\u30b9\u304c\u7d42\u4e86\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u30012021\u5e74\u6642\u70b9\u3067\u306f\u3001Livedoor\u5929\u6c17\u306eAPI\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u3066\u3082\u5929\u6c17\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n<h2>\u5929\u6c17\u4e88\u5831\u306fOpen Weather Map\u306eAPI\u3067\u7121\u6599\u53d6\u5f97\u53ef\u80fd<\/h2>\n<p>Livedoor\u5929\u6c17\u306eAPI\u30b5\u30fc\u30d3\u30b9\u304c\u7d42\u4e86\u3057\u3066\u3057\u307e\u3063\u305f\u4eca\u3001\u5929\u6c17\u4e88\u5831\u306a\u3069\u306e\u5929\u5019\u60c5\u5831\u3092\u3069\u3046\u3084\u3063\u3066\u53d6\u5f97\u3059\u308c\u3070\u3088\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>Livedoor\u5929\u6c17\u306e\u4ee3\u66ff\u3068\u3057\u3066\u5229\u7528\u3067\u304d\u308b\u30b5\u30fc\u30d3\u30b9\u3068\u3057\u3066\u300cOpen Weather Map\u300d\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u300cOpen Weather Map\u300d\u306f\u65e5\u672c\u3060\u3051\u3067\u306a\u304f\u4e16\u754c\u5404\u5730\u306e\u5929\u6c17\u60c5\u5831\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308b\u30b5\u30fc\u30d3\u30b9\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1614\" src=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001.jpg\" alt=\"\u4e16\u754c\u4e2d\u306e\u5929\u6c17\u60c5\u5831\u3092\u53d6\u5f97\u3067\u304d\u308b\u7121\u6599API\u300cOpenWeatherMap\u300d\u306eAPI\u30ad\u30fc\u767a\u884c\u30fb\u53d6\u5f97\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u65b9\u6cd5\u3092\u89e3\u8aac\" width=\"1200\" height=\"634\" srcset=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001.jpg 1200w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001-300x159.jpg 300w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001-768x406.jpg 768w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001-1024x541.jpg 1024w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001-530x280.jpg 530w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001-565x299.jpg 565w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001-710x375.jpg 710w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2020\/09\/20200914_auto_001-725x383.jpg 725w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>IT\u30a8\u30ad\u30b9\u30d1\u30fc\u30c8\u3068\u30c7\u30fc\u30bf\u30b5\u30a4\u30a8\u30f3\u30c6\u30a3\u30b9\u30c8\u306e\u30c1\u30fc\u30e0\u3067\u904b\u55b6\u3057\u3066\u304a\u308a\u3001\u672c\u90e8\u306f\u30a4\u30ae\u30ea\u30b9\u306e\u30ed\u30f3\u30c9\u30f3\u306b\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u300cOpen Weather Map\u300d\u306b\u306fAPI\u3067\u5929\u6c17\u3092\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u304a\u308a\u3001\u7121\u6599\u3067\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u7121\u6599API\u306e\u5834\u5408\u3001\u6709\u6599\u7248\u306b\u6bd4\u3079\u3001API\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u304d\u308b\u56de\u6570\u3084\u53d6\u5f97\u3067\u304d\u308b\u671f\u9593\u3001\u4f7f\u3048\u308b\u6a5f\u80fd\u306b\u5236\u7d04\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u500b\u4eba\u30ec\u30d9\u30eb\u306e\u30a2\u30d7\u30ea\u3084\u30b5\u30fc\u30d3\u30b9\u3067\u4e00\u822c\u7684\u306a\u5929\u6c17\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u5834\u5408\u306b\u306f\u3001\u7121\u6599\u7248\u3067\u3082\u6a5f\u80fd\u7684\u306b\u5341\u5206\u3067\u3059\u3002<\/p>\n<ol>\n<li>\u6307\u5b9a\u3057\u305f\u90fd\u5e02\u306e\u73fe\u5728\u306e\u5929\u6c17\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<li>\u6307\u5b9a\u3057\u305f\u90fd\u5e02\u306e\u51485\u65e5\u9593\u306e3\u6642\u9593\u3054\u3068\u306e\u5929\u6c17\u3092\u53d6\u5f97\u3059\u308b<\/li>\n<\/ol>\n<p>Open Weather Map\u3068Google Apps Script(GAS)\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u5929\u6c17\u306b\u95a2\u3059\u308b\u30b5\u30fc\u30d3\u30b9\u30fb\u30a2\u30d7\u30ea\u304c\u958b\u767a\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>Open Weather Map\u306eAPI\u5229\u7528\u624b\u9806<\/h2>\n<p>Open Weather Map\u306eAPI\u3092\u5229\u7528\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"Owc1dbGvri\"><p><a href=\"https:\/\/auto-worker.com\/blog\/?p=1612\">\u4e16\u754c\u306e\u5929\u6c17API\u300cOpenWeatherMap\u300d\u306e\u7121\u6599API\u30ad\u30fc\u767a\u884c\u30fb\u53d6\u5f97\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u65b9\u6cd5<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;\u4e16\u754c\u306e\u5929\u6c17API\u300cOpenWeatherMap\u300d\u306e\u7121\u6599API\u30ad\u30fc\u767a\u884c\u30fb\u53d6\u5f97\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u65b9\u6cd5&#8221; &#8212; AutoWorker\u301cGoogle Apps Script(GAS)\u3068Sikuli\u3067\u59cb\u3081\u308b\u696d\u52d9\u6539\u5584\u5165\u9580\" src=\"https:\/\/auto-worker.com\/blog\/?p=1612&#038;embed=true#?secret=fjna71NT90#?secret=Owc1dbGvri\" data-secret=\"Owc1dbGvri\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<p>\u7121\u6599\u7248\u306eOpen Weather Map\u306eAPI\u30ad\u30fc\u3067\u3042\u308c\u3070\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306b\u3088\u308b\u4f1a\u54e1\u767b\u9332\u3092\u884c\u3046\u3060\u3051\u3067API\u30ad\u30fc\u304c\u767a\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Open Weather Map\u306eAPI\u901a\u4fe1\u306fHTTP\u306eGET\u901a\u4fe1\u306e\u305f\u3081\u3001Chrome\u306a\u3069\u306e\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u7c21\u5358\u306b\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>API\u30ad\u30fc\u306e\u767a\u884c\u304c\u5b8c\u4e86\u3057\u305f\u3089\u3001\u6307\u5b9a\u3057\u305f\u90fd\u5e02\u306e\u73fe\u5728\u306e\u5929\u6c17\u3092\u53d6\u5f97\u3059\u308bAPI\u30ea\u30af\u30a8\u30b9\u30c8URL\u3092\u6253\u3061\u8fbc\u3093\u3067\u52d5\u4f5c\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><em><strong>http:\/\/api.openweathermap.org\/data\/2.5\/weather?q=<span style=\"color: #ff0000;\">{city}<\/span>&amp;appid=<span style=\"color: #ff0000;\">{key}<\/span>&amp;lang=ja&amp;units=metric<\/strong><\/em><\/p>\n<p>\u203b\u8d64\u5b57\u306e{city}\u306b\u5929\u6c17\u3092\u77e5\u308a\u305f\u3044\u90fd\u5e02(\u4f8b\uff1a\u6771\u4eac\u306e\u5834\u5408Tokyo,JP)\u3001{key}\u306bAPI\u30ad\u30fc\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/p>\n<h2>GAS\u3067\u73fe\u5728\u306e\u5929\u6c17\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h2>\n<p>Open Weather Map\u306eAPI\u30ad\u30fc\u304c\u53d6\u5f97\u3067\u304d\u305f\u3068\u3053\u308d\u3067\u3001Google Apps Script(GAS)\u3092\u4f7f\u3063\u3066\u3001\u5929\u6c17\u60c5\u5831\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u3001\u65e5\u672c\u306e\u5404\u5730\u57df\u306e\u4e3b\u89817\u90fd\u5e02\u306e\u73fe\u6642\u70b9\u306e\u5929\u6c17(\u5929\u5019\u3001\u6c17\u6e29\u3001\u6e7f\u5ea6\u3001\u6c17\u5727)\u3092\u53d6\u5f97\u3057\u3001\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u51fa\u529b\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><strong>\u203b\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u7d10\u3065\u304f\u5f62\u3067\u306eGAS\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4318\" src=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003.jpg\" alt=\"Google Apps Script(GAS)\u3067Open Weather Map\u306eAPI\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u3066\u65e5\u672c\u306e\u5927\u90fd\u5e02\u306e\u73fe\u5728\u306e\u5929\u6c17\u3092\u53d6\u5f97\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\" width=\"1200\" height=\"614\" srcset=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003.jpg 1200w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003-300x154.jpg 300w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003-768x393.jpg 768w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003-1024x524.jpg 1024w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003-530x271.jpg 530w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003-565x289.jpg 565w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003-710x363.jpg 710w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_003-725x371.jpg 725w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><code>function getWeatherInfo() {<br \/>\n\/\/Open Weather Map\u306eAPI\u30ad\u30fc\u3092\u5b9a\u7fa9\u3059\u308b(\u5404\u81eaAPI\u30ad\u30fc\u3067\u66f8\u304d\u63db\u3048)<br \/>\nlet apiKey = '********************************';<br \/>\nlet apiUrl = 'https:\/\/api.openweathermap.org\/data\/2.5\/weather?q=';<br \/>\n\/\/\u65e5\u672c\u306e\u5404\u5730\u65b9\u306e\u4e3b\u89817\u90fd\u5e02\u3092\u5b9a\u7fa9\u3059\u308b<br \/>\nlet cityList = ['Sapporo,JP','Sendai,JP','Tokyo,JP','Nagoya,JP','Osaka,JP','Hiroshima,JP','Fukuoka,JP'];<br \/>\n\/\/\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u66f8\u304d\u8fbc\u3080\u305f\u3081\u306e\u914d\u5217\u3092\u521d\u671f\u5316\u3059\u308b<br \/>\nlet weatherInfo = [];<br \/>\n\/\/\u4e3b\u89817\u90fd\u5e02\u5206\u306eAPI\u30ea\u30af\u30a8\u30b9\u30c8\u3092For\u30eb\u30fc\u30d7\u3067\u5b9f\u884c\u3059\u308b<br \/>\nfor(let i = 0; i &lt; cityList.length; i++){<br \/>\nweatherInfo[i] = [];<br \/>\n\/\/API\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308bURL\u306bAPI\u30ad\u30fc\u3068\u53d6\u5f97\u90fd\u5e02\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u30bb\u30c3\u30c8<br \/>\nlet requestUrl = apiUrl + cityList[i] + '&amp;appid=' + apiKey + '&amp;lang=ja&amp;units=metric';<br \/>\n\/\/UrlFetchApp\u3067Open Weather Map\u306eAPI\u304b\u3089\u5929\u6c17\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b<br \/>\nlet response = UrlFetchApp.fetch(requestUrl).getContentText();<br \/>\n\/\/\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u306fJSON\u5f62\u5f0f\u306e\u305f\u3081\u3001JSON\u3068\u3057\u3066\u5909\u63db\u3059\u308b<br \/>\nlet json = JSON.parse(response);<br \/>\n\/\/Open Weather Map\u304b\u3089\u53d6\u5f97\u3057\u305f\u5929\u6c17\u60c5\u5831\u306e\u4e2d\u304b\u3089\u5fc5\u8981\u306a\u60c5\u5831\u30922\u6b21\u5143\u914d\u5217\u306b\u66f8\u304d\u8fbc\u307f<br \/>\nweatherInfo[i][0] = json['name'];<br \/>\nweatherInfo[i][1] = json['weather'][0]['description'];<br \/>\nweatherInfo[i][2] = json['main']['temp_min'];<br \/>\nweatherInfo[i][3] = json['main']['temp_max'];<br \/>\nweatherInfo[i][4] = json['main']['humidity'];<br \/>\nweatherInfo[i][5] = json['main']['pressure'];<br \/>\n}<br \/>\n\/\/\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u7d10\u4ed8\u3044\u305f\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306e\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b7\u30fc\u30c8\u3092\u8aad\u307f\u8fbc\u307f<br \/>\nlet mySheet = SpreadsheetApp.getActiveSheet();<br \/>\n\/\/\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306bOpen Weather Map\u304b\u3089\u53d6\u5f97\u3057\u305f\u5929\u6c17\u60c5\u5831\u3092\u66f8\u304d\u8fbc\u307f<br \/>\nmySheet.getRange(2, 1, weatherInfo.length, weatherInfo[0].length).setValues(weatherInfo);<br \/>\n}<\/code><\/p>\n<p>3\u884c\u76ee\u306bOpen Weather Map\u306eAPI\u30ad\u30fc\u3092\u5909\u6570\u3067\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u3053\u3053\u306b\u7ba1\u7406\u753b\u9762\u304b\u3089\u767a\u884c\u3057\u305fAPI\u30ad\u30fc\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<p>\u4e88\u3081\u7528\u610f\u3057\u3066\u3044\u308b\u672d\u5e4c\u3001\u4ed9\u53f0\u3001\u6771\u4eac\u3001\u540d\u53e4\u5c4b\u3001\u5927\u962a\u3001\u5e83\u5cf6\u3001\u798f\u5ca1\u306e7\u90fd\u5e02\u306e\u6570\u3060\u3051For\u30eb\u30fc\u30d7\u3067\u51e6\u7406\u3057\u3066\u3001\u5404\u90fd\u5e02\u306e\u5929\u6c17\u60c5\u5831\u3092\u53d6\u5f97\u3057\u30012\u6b21\u5143\u914d\u5217\u306b\u5fc5\u8981\u306a\u5929\u6c17\u60c5\u5831\u3092\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u7d10\u4ed8\u3044\u3066\u3044\u308b\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306e\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b7\u30fc\u30c8\u306b2\u6b21\u5143\u914d\u5217\u306e\u5929\u6c17\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u51fa\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4316\" src=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002.jpg\" alt=\"Google Apps Script\u3067Open Weather Map\u306eAPI\u3067\u5927\u90fd\u5e02\u306e\u5929\u6c17\u60c5\u5831\u3092\u53d6\u5f97\u3057\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u51fa\u529b\" width=\"1200\" height=\"603\" srcset=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002.jpg 1200w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002-300x151.jpg 300w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002-768x386.jpg 768w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002-1024x515.jpg 1024w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002-530x266.jpg 530w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002-565x284.jpg 565w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002-710x357.jpg 710w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_002-725x364.jpg 725w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u306f\u5317\u6d77\u9053\u304b\u3089\u4e5d\u5dde\u307e\u3067\u306e\u5927\u90fd\u5e02\u306e\u73fe\u5728\u306e\u5929\u6c17\u60c5\u5831\u3092\u51fa\u529b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u51fa\u529b\u3057\u305f\u5929\u6c17\u60c5\u5831\u3092\u30a2\u30d7\u30ea\u3084Web\u30b5\u30fc\u30d3\u30b9\u306b\u6d3b\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>3\u6642\u9593\u3054\u3068\u306e\u5929\u6c17\u4e88\u5831(5\u65e5\u5148\u5206)\u3092\u53d6\u5f97\u3059\u308bGAS\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9<\/h2>\n<p>\u3055\u304d\u307b\u3069\u306fOpen Weather Map\u306eAPI\u3067\u73fe\u6642\u70b9\u306e\u5929\u6c17\u60c5\u5831\u3092\u65e5\u672c\u306e\u5404\u5730\u3067\u53d6\u5f97\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u6b21\u306f\u672a\u6765\u306e\u5929\u6c17\u60c5\u5831\u3067\u3042\u308b\u5929\u6c17\u4e88\u5831\u3092\u3001GAS\u304b\u3089Open Weather Map API\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<p>\u524d\u8ff0\u306eGAS\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3068\u306fOpen Weather Map\u306eAPI\u306e\u30ea\u30af\u30a8\u30b9\u30c8URL\u304c\u5909\u66f4\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><em><strong>http:\/\/api.openweathermap.org\/data\/2.5\/<span style=\"color: #ff0000;\">forecast<\/span>?q={city}&amp;appid={key}&amp;lang=ja&amp;units=metric<\/strong><\/em><\/p>\n<p>\u203b\u8d64\u5b57\u90e8\u5206\u304c\u300cweather\u2192forecast\u300d\u306b\u5909\u308f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18API\u306eURL\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\u3053\u3068\u3067\u3001\u6307\u5b9a\u3057\u305f\u90fd\u5e02\u306e5\u65e5\u9593\u5148\u306e3\u6642\u9593\u3054\u3068\u306e\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4319\" src=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004.jpg\" alt=\"Google Apps Script(GAS)\u3067Open Weather Map\u306eAPI\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u3066\u65e5\u672c\u306e\u90fd\u5e02\u306e5\u65e5\u9593\u5148\u307e\u3067\u306e3\u6642\u9593\u3054\u3068\u306e\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\" width=\"1200\" height=\"613\" srcset=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004.jpg 1200w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004-300x153.jpg 300w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004-768x392.jpg 768w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004-1024x523.jpg 1024w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004-530x271.jpg 530w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004-565x289.jpg 565w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004-710x363.jpg 710w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_004-725x370.jpg 725w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p><code>function getForecast() {<br \/>\n\/\/Open Weather Map\u306eAPI\u30ad\u30fc\u3092\u5b9a\u7fa9\u3059\u308b(\u5404\u81eaAPI\u30ad\u30fc\u3067\u66f8\u304d\u63db\u3048)<br \/>\nlet apiKey = '********************************';<br \/>\nlet apiUrl = 'https:\/\/api.openweathermap.org\/data\/2.5\/forecast?q=';<br \/>\n\/\/\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3059\u308b\u90fd\u5e02\u3092\u5b9a\u7fa9\u3059\u308b(\u4eca\u56de\u306f\u6771\u4eac\u3092\u8a2d\u5b9a)<br \/>\nlet city = 'Tokyo,JP';<br \/>\n\/\/API\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308bURL\u306bAPI\u30ad\u30fc\u3068\u53d6\u5f97\u90fd\u5e02\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u30bb\u30c3\u30c8<br \/>\nlet requestUrl = apiUrl + city + '&amp;appid=' + apiKey + '&amp;lang=ja&amp;units=metric';<br \/>\n\/\/UrlFetchApp\u3067Open Weather Map\u306eAPI\u304b\u3089\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3059\u308b<br \/>\nlet response = UrlFetchApp.fetch(requestUrl).getContentText();<br \/>\n\/\/\u53d6\u5f97\u3057\u305f\u30c7\u30fc\u30bf\u306fJSON\u5f62\u5f0f\u306e\u305f\u3081\u3001JSON\u3068\u3057\u3066\u5909\u63db\u3059\u308b<br \/>\nlet json = JSON.parse(response);<br \/>\n\/\/\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u66f8\u304d\u8fbc\u3080\u305f\u3081\u306e\u914d\u5217\u3092\u521d\u671f\u5316\u3059\u308b<br \/>\nlet weatherInfo = [];<br \/>\n\/\/\u4e3b\u89817\u90fd\u5e02\u5206\u306eAPI\u30ea\u30af\u30a8\u30b9\u30c8\u3092For\u30eb\u30fc\u30d7\u3067\u5b9f\u884c\u3059\u308b<br \/>\nfor (let i = 0; i &lt; json['list'].length; i++) {<br \/>\nweatherInfo[i] = [];<br \/>\n\/\/Open Weather Map\u304b\u3089\u53d6\u5f97\u3057\u305f\u5929\u6c17\u4e88\u5831\u306e\u4e2d\u304b\u3089\u5fc5\u8981\u306a\u60c5\u5831\u30922\u6b21\u5143\u914d\u5217\u306b\u66f8\u304d\u8fbc\u307f<br \/>\nweatherInfo[i][0] = json['list'][i]['dt_txt'];<br \/>\nweatherInfo[i][1] = json['list'][i]['weather'][0]['description'];<br \/>\nweatherInfo[i][2] = json['list'][i]['main']['temp_min'];<br \/>\nweatherInfo[i][3] = json['list'][i]['main']['temp_max'];<br \/>\nweatherInfo[i][4] = json['list'][i]['main']['humidity'];<br \/>\nweatherInfo[i][5] = json['list'][i]['main']['pressure'];<br \/>\n}<br \/>\n\/\/\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u7d10\u4ed8\u3044\u305f\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306e\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u30b7\u30fc\u30c8\u3092\u8aad\u307f\u8fbc\u307f<br \/>\nlet mySheet = SpreadsheetApp.getActiveSheet();<br \/>\n\/\/\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306bOpen Weather Map\u304b\u3089\u53d6\u5f97\u3057\u305f\u5929\u6c17\u4e88\u5831\u3092\u66f8\u304d\u8fbc\u307f<br \/>\nmySheet.getRange(1,1).setValue(city);<br \/>\nmySheet.getRange(2, 1, weatherInfo.length, weatherInfo[0].length).setValues(weatherInfo);<br \/>\n}<\/code><\/p>\n<p>GAS\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u306f\u30013\u884c\u76ee\u306bAPI\u30ad\u30fc\u3092\u30bb\u30c3\u30c8\u3059\u308b\u3088\u3046\u306b\u3057\u3001\u53d6\u5f97\u3059\u308b\u90fd\u5e02\u306f6\u884c\u76ee\u3067\u6771\u4eac\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u53d6\u5f97\u3059\u308b\u5929\u6c17\u4e88\u5831\u306e\u30c7\u30fc\u30bf\u306f\u5929\u5019\u3001\u6700\u4f4e\u6c17\u6e29\u3001\u6700\u9ad8\u6c17\u6e29\u3001\u6e7f\u5ea6\u3001\u6c17\u5727\u3067\u3059\u304c\u3001\u5408\u308f\u305b\u3066\u5929\u6c17\u4e88\u5831\u306e\u6642\u523b\u30822\u6b21\u5143\u914d\u5217\u306b\u683c\u7d0d\u3057\u3001\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u51fa\u529b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4320\" src=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005.jpg\" alt=\"Google Apps Script(GAS)\u3067Open Weather Map\u306eAPI\u3092\u30ea\u30af\u30a8\u30b9\u30c8\u3057\u3066\u65e5\u672c\u306e\u90fd\u5e02\u306e5\u65e5\u9593\u5148\u307e\u3067\u306e3\u6642\u9593\u3054\u3068\u306e\u5929\u6c17\u4e88\u5831\u3092\u30b9\u30d7\u30ec\u30c3\u30c9\u30b7\u30fc\u30c8\u306b\u51fa\u529b\" width=\"1200\" height=\"604\" srcset=\"https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005.jpg 1200w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005-300x151.jpg 300w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005-768x387.jpg 768w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005-1024x515.jpg 1024w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005-530x267.jpg 530w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005-565x284.jpg 565w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005-710x357.jpg 710w, https:\/\/auto-worker.com\/blog\/wp-content\/uploads\/2021\/09\/20210912_auto_005-725x365.jpg 725w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u7121\u6599\u7248\u306eOpen Weather Map\u306eAPI\u3067\u3082\u7279\u5b9a\u90fd\u5e02\u306e5\u65e5\u9593\u5148\u306e3\u6642\u9593\u3054\u3068\u306e\u5929\u6c17\u4e88\u5831\u304c\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3067\u304d\u308c\u3070\u3001\u5098\u304c\u5fc5\u8981\u3068\u901a\u77e5\u3059\u308b\u30a2\u30d7\u30ea\u306a\u3069\u6d3b\u7528\u4e8b\u4f8b\u306f\u3055\u3089\u306b\u5e45\u304c\u5e83\u304c\u308a\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081\u30fb\u7d42\u308f\u308a\u306b<\/h2>\n<p>\u4eca\u56de\u3001Google Apps Script(GAS)\u3067\u5929\u6c17\u60c5\u5831(\u5929\u6c17\u4e88\u5831)\u3092Open Weather Map\u306e\u7121\u6599API\u3067\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3092\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u304b\u3064\u3066\u306fGAS\u3067\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3059\u308b\u306e\u306fLivedoor\u5929\u6c17\u306e\u7121\u6599API\u304c\u4e00\u822c\u7684\u3067\u3057\u305f\u304c\u30012020\u5e747\u6708\u306b\u30b5\u30fc\u30d3\u30b9\u304c\u7d42\u4e86\u3057\u305f\u305f\u3081\u3001\u7121\u6599\u3067\u5229\u7528\u3067\u304d\u308bOpen Weather Map\u306eAPI\u304c\u30aa\u30b9\u30b9\u30e1\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306bGAS\u3067\u73fe\u5728\u306e\u5929\u6c17\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u30685\u65e5\u9593\u5148\u306e\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u306e2\u7a2e\u985e\u3092\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5929\u6c17\u60c5\u5831\u306f\u65e5\u5e38\u751f\u6d3b\u306b\u304a\u3044\u3066\u3001\u5fc5\u8981\u4e0d\u53ef\u6b20\u3068\u3044\u3048\u308b\u306e\u3067\u3001\u8272\u3005\u306a\u30a2\u30d7\u30ea\u3084\u30b5\u30fc\u30d3\u30b9\u306b\u5fdc\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u7121\u6599\u3067\u7c21\u5358\u306b\u5229\u7528\u3067\u304d\u308bOpen Weather Map API\u3068GAS\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001\u5929\u6c17\u4e88\u5831\u3092\u6d3b\u7528\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Apps Script(GAS)\u3067\u5929\u6c17\u4e88\u5831\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5\u3057\u307e\u3059\u3002 \u30cd\u30c3\u30c8\u3067\u306fLivedoor\u5929\u6c17API\u3092\u4f7f\u3063\u305f\u89e3\u8aac\u8a18\u4e8b\u304c\u591a\u3044\u3067\u3059\u304c\u30012020\u5e74\u306b\u30b5\u30fc\u30d3\u30b9\u7d42\u4e86\u3057\u305f\u305f\u3081\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002 2021\u5e74\u3067\u3082\u4f7f\u7528\u53ef\u80fd\u306a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4318,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,2],"tags":[14,428,635],"class_list":["post-3298","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-api","category-gas","tag-gas","tag-open-weather-map","tag-635"],"_links":{"self":[{"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3298","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3298"}],"version-history":[{"count":3,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3298\/revisions"}],"predecessor-version":[{"id":4321,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3298\/revisions\/4321"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/4318"}],"wp:attachment":[{"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3298"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3298"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/auto-worker.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3298"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}