Created
September 13, 2022 13:29
-
-
Save Tomokatsu-Sakamoto/aeb8c911e787714a86d1ede9e4526798 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//chatにメッセージを送信する | |
function sendChatMessage() { | |
const sheet = SpreadsheetApp.getActiveSheet(); // アクティブなシートを取得 | |
//投稿先指定 | |
const url = sheet.getRange("B1").getValue(); | |
//送信内容作成 | |
let message = | |
{ | |
'text': sheet.getRange("B2").getValue() | |
}; | |
let params = { | |
'method': 'POST', | |
'muteHttpExceptions' : true, | |
'headers': { | |
'Content-Type': 'application/json; charset=UTF-8' | |
}, | |
'payload': JSON.stringify(message) | |
}; | |
//送信 | |
try { | |
let result = UrlFetchApp.fetch(url, params); | |
Logger.log(result); | |
sheet.getRange("B3").setValue(result); | |
} | |
catch (e) { | |
Logger.log(e); | |
sheet.getRange("B3").setValue(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment