//script calling the published script, this script is in the account 1
function callScript(){
try{//published url
var response =UrlFetchApp.fetch("https://script.google.com/macros/s/../exec? calendar='CalendarName'");//calendar name as parameter
}catch(e){
Logger.log(e);
}
Logger.log(response.getContentText());
}
//account 2
//the code is published, it will run as the user who call the script(account 1), the access is for anyone
function doGet(e){//published script
var app = UiApp.createApplication();
var calendar=e.parameter.calendar; //calendar name as parameter
// Determines how many events are happening now
var now = new Date();
var oneMinuteFromNow = new Date(now.getTime() + (60 * 1000));
var events = CalendarApp.getCalendarsByName(calendar) [0].getEvents(now,oneMinuteFromNow);
var email=Session.getActiveUser().getEmail();
for(i in events){
var tituloEvento=events[i].getTitle();
var descEvento= events[i].getDescription();
var insertar=leerBD(email,tituloEvento,descEvento);
if (insertar) {
var inserto=insertarBD(email,tituloEvento,descEvento);
}
}
return ContentService.createTextOutput(e.parameter.string.calendar);
}
我想在帐户 2 中调用脚本并将日历名称作为参数传递,在帐户 2 中,脚本将以调用脚本并获取一些事件的用户身份运行