[英]Finding email of calendar owner in the response of google calendar API's events.list?
我正在開發一個Web應用程序,顯示我的同事的日歷統計信息。 要顯示此人的電子郵件,我使用的是一個名為“summary”的字段(基本上,響應對象不包含id
字段。它只有summary
字段。)
在大多數情況下,這是該人的電子郵件。 有用。
但如果此人將日歷名稱更改為“工作”或其他內容,則會顯示為“工作”而不是“cathie@mydomain.com”。 在那種情況下,我無法知道他/她的電子郵件,因此我無法打印這些統計數據。
質詢
gapi.client.calendar.events.list
響應的API響應中是否有一個字段,其中包含日歷所有者的電子郵件?
是否有任何javascript技巧將此信息(calendarId)傳遞到'request.execute(function(resp)'
並從回調函數內部訪問它?
如果有標准的方法,請建議。
function getStatistics() {
people = ['Alice', 'Bob', 'Cathie'];
people.forEach(fetchStats);
}
function fetchStats(person) {
var calendarId = person + '@mydomain.com';
// ... some code
var request = gapi.client.calendar.events.list({
'calendarId': calendarId,
'timeMax': (new Date()).toISOString(),
'timeMin': '2016-01-01T00:00:00+05:30'
});
request.execute(function(resp) {
var calendarId = resp.summary;
if (calendarId.indexOf('@') == -1) {
window.alert(resp + "\n" + calendarId);
return;
}
// code to render statistics on events of the calendarId
);
}
function getStatistics() {
people = ['Alice', 'Bob', 'Cathie'];
people.forEach(fetchStats);
}
function fetchStats(person) {
var calendarId = person + '@mydomain.com';
// ... some code
var request = gapi.client.calendar.events.list({
'calendarId': calendarId,
'timeMax': (new Date()).toISOString(),
'timeMin': '2016-01-01T00:00:00+05:30'
});
request.execute(function(resp) {
//use the calendarId variable set above
if (calendarId.indexOf('@') == -1) {
window.alert(resp + "\n" + calendarId);
return;
}
// code to render statistics on events of the calendarId
});
}
您所要做的就是刪除回調中calendarId的本地設置。 回調仍然可以在你的fetchStats函數的范圍內引用,我只是測試它,它似乎工作正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.