0
我剛剛開始我的JS旅程。目前正試圖在Google表格腳本中更新MailChimp API調用。問題在於,腳本(最初在此處找到:https://medium.hackinrio.com/mailchimp-reports-in-google-sheets-88496a153ee21)僅在保存Google腳本編輯器時起作用。我想創建一個JavaScript GAS函數,它能夠每天保存腳本編輯器,從而更新MailChimp計數。或者其他一些解決方案,可以讓這個工作。需要創建一個保存谷歌應用程序腳本(或修復原來的功能)的功能
谷歌腳本功能:
function getSubscribersCount(api_key, list_id) {
var API_KEY = api_key;
var LIST_ID = list_id;
var dc = '(my mailchimp API Key goes here)'.split('-')[1];
var api = 'https://'+ dc +'.api.mailchimp.com/2.0';
var membersPath = '/lists/members.json';
// MC api-specific parameters
var payload = {
"apikey": API_KEY,
"id": LIST_ID
};
// GAS specific parameters:
var params = {
"method": "POST",
"muteHttpExceptions": true,
"payload": payload
};
var apiCall = function(endpoint){
var apiResponse = UrlFetchApp.fetch(api+endpoint, params);
var json = JSON.parse(apiResponse);
return json;
};
var members = apiCall(membersPath);
return members.total;
}
是否有一個功能,我可以補充一點,使我得以保存功能,或者模擬CMD +的鍵盤事件?