Created
February 10, 2018 15:20
-
-
Save shunirr/231569d833cd08cb3f9747f3f8817ee5 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(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