2011-04-04 51 views
11

嘿,我能夠驗證和授權用戶使用谷歌日曆的JavaScript API。我想接下來要做的是訂閱該用戶的公共日曆。我想我可能只是調用google.gdata.calendar.CalendarEntry構造與日曆的ID,但如何以編程方式將用戶訂閱到使用JavaScript的Google日曆?

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

我還試圖創建與google.gdata一個條目ID的一個實例,沒有工作。 atom.Id( 「idOfCalendar」);並將其添加到CalendarEntry構造函數中。使用set方法也無效。

我用InsertEntry方法添加的條目,但我得到以下錯誤

Error: Valid calendar id must be supplied for adding calendar to favorites list in allcalendars projection.

我可以訪問該日曆的使用google.gdata.calendar.CalendarEventQuery()

事件在谷歌API的API並沒有給出很多例子,任何人都知道我的問題的答案或與谷歌日曆API的工作良好的資源?你認爲我應該使用PHP還是傑森?

**編輯 我發現了什麼,我想在Java API中link一個例子,所以我試圖

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[email protected]"); 
    calendarService.insertEntry(feedUri, calendarEntry, function(){alert("calendar added")}, handleError); 
} 

,但我得到了同樣的錯誤

回答

2

您應該使用owncalendars飼料修改/添加對身份驗證的用戶沒有allcalendars日曆條目。

1

聽起來就像你的日曆ID無效。你的第二個例子中的id似乎是URL編碼的。嘗試使用解碼值:

nhl_21_Toronto Maple Leafs#[email protected]

相關問題