Created
October 18, 2023 04:07
-
-
Save Mulannnnn/cad1144fe0bf6938e09a45e9f1a2945a 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
function doGet(request){ | |
//push noti api | |
var lntoken = 'YOUR_NOTIFY_TOKEN' | |
var messagefrom = request.parameter.messagefrom | |
var message = request.parameter.message | |
message = '\nmessage from: '+messagefrom+'\n\nmessage: '+message | |
var result = sendLineNotify(lntoken,message) | |
result = JSON.stringify(result); | |
return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.JSON); | |
} | |
function sendLineNotify(token,message) { | |
//create line noti payload | |
var options = { | |
"method": "post", | |
"payload": "message=" + message, | |
"headers": { | |
"Authorization": "Bearer " + token | |
} | |
}; | |
var response = UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options); | |
response = response.getContentText() | |
var result = JSON.parse(response) | |
//part to return result as intent | |
if (result['status']===200){ | |
res = {} | |
res['resultoutput'] = 'in_notisent' | |
Logger.log('ok') | |
} else{ | |
res = {} | |
res['resultoutput'] = 'in_notierror' | |
} | |
Logger.log(res) | |
return res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment