13

Hey i'm able to authenticate and authorize a user with the javascript API for google calendar. what i want to do next is subscribe that user to a public calendar. I was thinking i could just call the google.gdata.calendar.CalendarEntry constructor with the id of the calendar but that didn't work

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

i also tried creating an instance of a entry id with google.gdata.atom.Id("idOfCalendar"); and adding that to the CalendarEntry constructor. Using the set methods didn't work either.

I use the InsertEntry method to add the entry but i get the following error

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

I can access the events of this calendar using google.gdata.calendar.CalendarEventQuery()

The google api for javascript doesn't give a lot of examples anyone know the answer to my problem or a good resource for working with the google calendar api? do you think i should be using php or jason instead?

** Edit I found an example of what I want in the Java Api link so i tried

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

but i got the same error

Kara
  • 6,115
  • 16
  • 50
  • 57
Devin Crossman
  • 7,454
  • 11
  • 64
  • 102

3 Answers3

3

You should be using owncalendars feed to modify/add calendar entry for the authenticated user not allcalendars.

Sarath
  • 106
  • 4
1

Sounds like your calendar id is invalid. The id from your second example appears to be URL encoded. Try using the decoded value:

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

Russell Davis
  • 8,319
  • 4
  • 40
  • 41
0

The gdata API for calendars has been switched off; the new way to do this is via: https://developers.google.com/google-apps/calendar/v3/reference/calendarList/insert

askvictor
  • 3,621
  • 4
  • 32
  • 45