2017-04-10 45 views
0

我正在爲谷歌日曆的應用程序工作。我可以獲取日曆,創建活動並顯示它們,但我似乎無法更新特定的日曆元數據。更新谷歌日曆說明javascript

我有這個功能

function setCalendarDescription(calendarId) { 

var send ={ 
    "resource" :{ 
    "description" : "test" 
    } 
}; 
console.log(send); 
var request = gapi.client.calendar.calendars.update({ 
    'calendarId': calendarId, 
    'resource': send 

}); 
console.log(request); 
request.execute(function(resp) { 
    alert("updated description in calendar"); 
}); 
} 

和IM稱它在這個函數

function listCalendars() { 
var request = gapi.client.calendar.calendarList.list(); 

request.execute(function(resp) { 
    var calendars = resp.items; 
    var counter = 0; 
    //console.log(calendars); 
    for (i = 0; i < resp.items.length; i++) { 

     var calendar = resp.items[i]; 
     var calId = calendar.id; 
     var calName = calendar.summary; 
     var accessRole = calendar.accessRole; 
     if (accessRole == "owner") { 

      var ulEvents = document.getElementById("events"); 
      var nH3 = document.createElement('ul'); 
      var nH3Text = document.createTextNode("Upcoming events for calendar " + calName + ":"); 
      nH3.appendChild(nH3Text); 
      nH3.setAttribute("id", "upcoming" + i); 
      ulEvents.appendChild(nH3); 
      listUpcomingEvents(calId, counter); 
      calendarArray[counter] = calendar; 
      setCalendarDescription(calId); 
      counter++; 
     } 

    } 

}); 
} 

我已經看過here的解決方案和網絡,但還沒有找到一個。

如果有人有一些方向,我會很感激。 謝謝

回答

0

我沒有看夠徹底的文件,答案就在那裏。 僅提供日曆說明是不夠的,您需要提供

description  string Description of the calendar. 
location  string Geographic location of the calendar as free-form text. 
summary   string Title of the calendar. 
timeZone  string The time zone of the calendar.