0
votes

I have been using this to try and work out how to get a list of information about people attending an event.

https://developers.google.com/google-apps/calendar/v3/reference/events/get#response

Currently I am using the code to below which provides me with a list of event names and summarys

var request = gapi.client.calendar.events.list({
    'calendarId': 'primary',
    'timeMin': (new Date()).toISOString(),
    'showDeleted': false,
    'singleEvents': true,
    'maxResults': 10,
    'orderBy': 'startTime'
});

 var select = document.getElementById("selectNumber");
    var options = resp.items;
    if (options.length > 0) {
        for (g = 0; g < options.length; g++) {
            var opt = options[g];
            var el = document.createElement("option");
            el.textContent = opt.id;
            el.value = opt.id;
            select.appendChild(el);
        }
    }
    else {

    }

I am unsure how to use this data in order to request more information about an event attendees email because ultimately i want to send an email to some of the attendess listed. Never worked with the google calendar api before. Any help appreciated.

2

2 Answers

1
votes

I worked it out I needed to call from gapi.client.calendar.events.get and use the gapi.client.calendar.events.list to get a list of the current events from that i was able to get the id and use that when the form posted

var eventSearch = $("#selectNumber option:selected").attr('value')

//alert(eventSearch);

var request2 = gapi.client.calendar.events.get({
    'calendarId': 'primary',
    'eventId': eventSearch
    //'fields': 'attendees(displayName,email,id)'


});
request2.execute(function(resp2) {

    alert(calenderId);
});
0
votes

After retrieving the events with the gapi.client.calendar.events.list() you can get their information something like this (that worked for me):

request.execute(function(resp) {
    var events = resp.items;
    console.log(events);
    for (i = 0; i < events.length; i++) {
        var event = events[i];
        var eventId = event.id;
        var eventSummary= event.summary;
        var eventAttendees = event.attendees;
    }
}

Once event.summary is an array, you can work with it.

I hope it helps you (I'm also learning and studying how to program with Google Calendar API and Javascript) :)