Skip to content

Instantly share code, notes, and snippets.

@shunirr
Created February 10, 2018 15:20
Show Gist options
  • Save shunirr/231569d833cd08cb3f9747f3f8817ee5 to your computer and use it in GitHub Desktop.
Save shunirr/231569d833cd08cb3f9747f3f8817ee5 to your computer and use it in GitHub Desktop.
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