How to programmatically subscribe a user to a google calendar using javascript? - Stack Overflow

Hey i'm able to authenticate and authorize a user with the javascript API for google calendar. wha

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 = "";
    var calendarEntry = new google.gdata.calendar.CalendarEntry();
    calendarEntry.setId("nhl_21_%54oronto+%4daple+%4ceafs#[email protected]");
    calendarService.insertEntry(feedUri, calendarEntry, function(){alert("calendar added")}, handleError);
}

but i got the same error

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./calendar/feeds/default/allcalendars/full";
    var calendarEntry = new google.gdata.calendar.CalendarEntry();
    calendarEntry.setId("nhl_21_%54oronto+%4daple+%4ceafs#[email protected]");
    calendarService.insertEntry(feedUri, calendarEntry, function(){alert("calendar added")}, handleError);
}

but i got the same error

Share Improve this question edited Dec 12, 2013 at 5:23 Kara 6,22616 gold badges53 silver badges58 bronze badges asked Apr 4, 2011 at 5:05 Devin CrossmanDevin Crossman 7,60213 gold badges67 silver badges102 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

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

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#[email protected]

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743747964a4500361.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信