Created
November 2, 2018 00:17
-
-
Save mokapyo/67c8a40af1a3a3cceb89ce49f653988b 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
/** | |
* MemoSendLINE | |
* GoogleHomeからお買い物メモをLINEで通知する | |
*/ | |
function doGet(e) { | |
// Googleスプレッドシートから買い物メモを取得 | |
var ss = SpreadsheetApp.openById("<スプレッドシートのID>"); | |
var sheet = ss.getSheetByName("shopping"); | |
var msg = "\n*****[お買い物メモ]******\n"; | |
for(var i=1;i<=sheet.getDataRange().getLastRow();i++){ | |
msg = msg + sheet.getRange(i, 2).getValue() + "\n"; | |
} | |
msg = msg +"**********************"; | |
// メッセージ送信 | |
sendLineMsg(msg); | |
} | |
/** | |
* LINE Notifyでルームにメッセージを送る | |
* @param {var} message 送信するメッセージ | |
*/ | |
function sendLineMsg(message){ | |
var token = "<取得したトークン>"; | |
var options = { | |
"method" : "post", | |
"payload" : "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