更新Google日历说明javascript

时间:2017-04-10 14:23:50

标签: javascript google-calendar-api

我正在处理谷歌日历的应用程序。我可以获取日历,创建事件并显示它们,但我似乎无法更新特定的日历元数据。

我有这个功能

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");
});
}

我在这个函数中调用它

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寻找解决方案和网络,但还没找到。

如果有人有方向,我会很感激。 感谢

1 个答案:

答案 0 :(得分: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.