我想在google脚本的帮助下从特定事件中获取eventID。我目前正在使用这个变量:
function export_gcal_to_gsheet(){
// Reference Websites:
// https://developers.google.com/apps-script/reference/calendar/calendar
// https://developers.google.com/apps-script/reference/calendar/calendar-event
//
var mycal = "info@neugier.schule";
var cal = CalendarApp.getCalendarById(mycal);
var today = new Date()
var thisweek = new Date (today.getTime())
var oneWeekfromNow = new Date(today.getTime() + (7*3600000*24));
//
var events = cal.getEvents(thisweek, oneWeekfromNow, {search: 'stammtisch'});
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Termine");
// Uncomment this next line if you want to always clear the spreadsheet content before running - Note people could have added extra columns on the data though that would be lost
//sheet.clearContents();
// Create a header record on the current spreadsheet in cells A1:N1 - Match the number of entries in the "header=" to the last parameter
// of the getRange entry below
var header = [["Event Title", "Event Start", "Thema", "LinkZoom", "EventID"]]
var range = sheet.getRange(1,1,1,5);
range.setValues(header);
// Loop through all calendar events found and write them out starting on calulated ROW 2 (i+2)
for (var i=0;i<events.length;i++) {
var row=i+2;
var myformula_placeholder = '';
// Matching the "header=" entry above, this is the detailed row entry "details=", and must match the number of entries of the GetRange entry below
// NOTE: I've had problems with the getVisibility for some older events not having a value, so I've had do add in some NULL text to make sure it does not error
var details=[[events[i].getTitle(), Utilities.formatDate(events[i].getStartTime(),'Europe/Berlin', 'dd.MM.yyyy,\' um\' HH:mm\'Uhr\''), events[i].getDescription(), events[i].getLocation(), events[i].getId()]];
var range=sheet.getRange(row,1,1,5);
range.setValues(details);
}
}
但似乎getId与事件ID不同,因为当我将ID插入此链接时:https://www.google.com/calendar/event?eid= {event-id}&amp; ctz = {timezone}
我收到错误。此外,当我手动共享我的事件时,我看到的ID与我从脚本中获取的ID不同。
希望有人可以帮助我。
答案 0 :(得分:1)
我们了解您希望https://www.google.com/calendar/event?eid={event-id}&ctz={timezone}
使用event-id
。我的理解是否正确?如果我的理解是正确的,那么这个修改怎么样?
https://www.google.com/calendar/event?eid={event-id}&ctz={timezone}
Calendar.Events.list()
,您可以使用function export_gcal_to_gsheet(){
var mycal = "info@neugier.schule";
var cal = CalendarApp.getCalendarById(mycal);
var today = new Date()
var thisweek = new Date (today.getTime())
var oneWeekfromNow = new Date(today.getTime() + (7*3600000*24));
var events = cal.getEvents(thisweek, oneWeekfromNow, {search: 'stammtisch'});
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Termine");
var header = [["Event Title", "Event Start", "Thema", "LinkZoom", "EventID"]]
var range = sheet.getRange(1,1,1,5);
range.setValues(header);
// Added
var items = Calendar.Events.list(mycal, {
timeMin: thisweek.toISOString(),
timeMax: oneWeekfromNow.toISOString(),
q: 'stammtisch'
}).items;
for (var i=0;i<events.length;i++) {
var row=i+2;
var myformula_placeholder = '';
var details=[[events[i].getTitle(), Utilities.formatDate(events[i].getStartTime(),'Europe/Berlin', 'dd.MM.yyyy,\' um\' HH:mm\'Uhr\''), events[i].getDescription(), events[i].getLocation(), items[i].htmlLink.split("=")[1]]]; // Modified
var range=sheet.getRange(row,1,1,5);
range.setValues(details);
}
}
Calendar API检索它。使用此修改过的脚本时,请在Advanced Google Services和API控制台上启用Calendar API。
htmlLink
Calendar.Events.list()
检索https://www.google.com/calendar/event?eid={event-id}
。链接为event-id
。现在,我使用items[i].htmlLink.split("=")[1]
从链接中检索items[i].htmlLink
以匹配您的脚本。如果您需要该链接,请将其修改为sma<-sma(data = forewing_R ,formula = y~x*groups,
method = "SMA", type = "shift", log = "xy")
plot(sma, col = c("Black", "Red", "Blue", "Dark Green"),
pch= c(5:10), log = "xy")
legend(0.765, 0.84, c("Control", "Low", "Medium", "High"),
pch = c(5,7,8,6), col=c("Black", "Blue", "Dark Green", "Red"))
。如果我误解了你的问题,我很抱歉。