Skip to content

Instantly share code, notes, and snippets.

@neno-tech
Last active May 25, 2022 13:52
Show Gist options
  • Save neno-tech/fc64d47b307d73b8e44bae82737a9a37 to your computer and use it in GitHub Desktop.
Save neno-tech/fc64d47b307d73b8e44bae82737a9a37 to your computer and use it in GitHub Desktop.
โค้ดไลน์แจ้งเตือนข่าว + รูปภาพ
=ArrayFormula(IFERROR(VLOOKUP(B2,Room!A:B,2,0),"ไม่มีข้อมูล"))
function send_News() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("News");
var lastRows = sheet.getLastRow();
var message="";
for(var i=2;i<=lastRows;i++) {
var token = sheet.getRange(i,1).getValue()
message = sheet.getRange(i,3).getValue()
var image = sheet.getRange(i,4).getValue()
if(sheet.getRange(i,5).getValue()==true){
sendLineNotify(message, token, image)
}
}
}
function sendLineNotify(message, token, image){
var options =
{
"method" : "post",
"payload" :
{
"image": "image",
"imageThumbnail" : image, // max size 240x240px JPEG
"imageFullsize" : image, //max size 1024x1024px JPEG
"message" : message,
},
"headers" : {"Authorization" : "Bearer " + token}
};
UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment