Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function doGet(e) {
if (!e.parameters.token || !e.parameters.signal_ids) {
return ContentService.createTextOutput('Invalid paramerter');
}
var token = e.parameters.token;
var signals = e.parameters.signal_ids.toString().split(',');
if (!token || !signals || signals.length < 1) {
return ContentService.createTextOutput('NG');
}
for (var i = 0; i < signals.length; i++) {
postSignalSendAPI(token, signals[i]);
Utilities.sleep(300);
}
return ContentService.createTextOutput('OK');
}
function postSignalSendAPI(token, signal_id){
var options = {
"method" : "post",
"headers" : {
"Authorization" : "Bearer " + token,
"Accept" : "application/json"
},
"payload" : {}
};
UrlFetchApp.fetch("https://api.nature.global/1/signals/" + signal_id + "/send", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment