0
function checkACBalance() {
try{
var url ="http://sms.mydomain.com/api/balance.php";
alert(url);
var payload = {authkey:'d5558466554f11aa909d565ede677d40', route:'1'};
alert(payload);
var payload_json = encodeURIComponent(JSON.stringify(payload));
alert(payload_json);
var options = {method:"POST",contentType:"application/json",payload:payload_json,muteHttpExceptions:true};
var result = UrlFetchApp.fetch(url, options);
var response = result.getContentText();
alert(response)
var res_code = result.getResponseCode();
alert(res_code)
}catch(e){
alert(e)
}
}
現在的問題是,當我使用此URLFetch
類調用外部API時,這不起作用。 在瀏覽器控制檯錯誤已經顯示出:如何通過URLFetch使用Google App腳本調用外部API
Uncaught TypeError: Cannot read property 'fetch' of undefined
這個'checkACBalance'功能在哪裏呢?在GAS'code.gs'文件中使用HTML