13

嘿,我能够使用用于谷歌日历的 javascript API 对用户进行身份验证和授权。我接下来要做的是为该用户订阅公共日历。我在想我可以用日历的 id 调用 google.gdata.calendar.CalendarEntry 构造函数,但这不起作用

var entry = google.gdata.calendar.CalendarEntry("idOfCalendar");

我还尝试使用 google.gdata.atom.Id("idOfCalendar"); 创建条目 id 的实例;并将其添加到 CalendarEntry 构造函数中。使用 set 方法也不起作用。

我使用 InsertEntry 方法添加条目,但出现以下错误

错误:必须提供有效的日历 ID 才能将日历添加到 allcalendars 投影中的收藏夹列表。

我可以使用 google.gdata.calendar.CalendarEventQuery() 访问此日历的事件

用于 javascript 的 google api 没有提供很多示例,任何人都知道我的问题的答案或使用 google calendar api 的好资源?你认为我应该改用 php 还是 jason?

** 编辑我在 Java Api链接中找到了我想要的示例,所以我尝试了

function addSubscriptionToCalendar() {
    var feedUri = "http://www.google.com/calendar/feeds/default/allcalendars/full";
    var calendarEntry = new google.gdata.calendar.CalendarEntry();
    calendarEntry.setId("nhl_21_%54oronto+%4daple+%4ceafs#sports@group.v.calendar.google.com");
    calendarService.insertEntry(feedUri, calendarEntry, function(){alert("calendar added")}, handleError);
}

但我得到了同样的错误

4

3 回答 3

3

您应该使用owncalendars提要为经过身份验证的用户而不是allcalendars修改/添加日历条目。

于 2011-05-03T20:49:01.060 回答
1

听起来您的日历 ID 无效。第二个示例中的 id 似乎是 URL 编码的。尝试使用解码后的值:

nhl_21_Toronto Maple Leafs#sports@group.v.calendar.google.com

于 2011-04-19T06:43:14.227 回答
0

日历的 gdata API 已关闭;新的方法是通过:https ://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert

于 2016-04-19T22:02:08.907 回答