Reputation: 97
I am trying to display events from a "public" google calendar. My requirement is to get the number of attendees (not necessarily the names of the attendees). However, when I get the events using the Calendar API (using an API Key and CalendarID); the event is missing the whole attendees section that is mentioned here.
My question: Do I need to be authenticated ? Does this mean this can't be public, and the web-pages that displays this information will need the "viewer" to authenticate to Google first?
Here is a snippet of my code (edited)...
$.ajax({
type: 'GET',
url: encodeURI('https://www.googleapis.com/calendar/v3/calendars/' + calendarId+ '/events?key=' + myKey),
dataType: 'json',
success: function (response) {
console.log(response);
//here is where I need to get the number of participants
},
error: function (error) {
console.log(error);
//tell that an error has occurred
}
Here is the output...
{kind: 'calendar#events', etag: '"p324e9j5nqabva0g"', summary: 'EDWC Schedule', description: '', updated: '2022-01-04T08:09:10.933Z', …} accessRole: 'reader' defaultReminders: (0) [] description: '' etag: '""' items: (2) [{…}, {…}] 0: {kind: 'calendar#event', etag: '""', id: '', status: 'confirmed', htmlLink:…} 1: {kind: 'calendar#event', etag: '""', id: '', status: 'confirmed', htmlLink:…} conferenceData: {} created: '' creator: {} description: '' end: {dateTime: '2022-01-08T16:00:00+11:00', timeZone: 'Australia/Sydney'} etag: '' eventType: 'default' hangoutLink: '' htmlLink: '' iCalUID: '' id: '' kind: 'calendar#event' location: 'Australia' organizer: {email: '', displayName: '', self: true} sequence: 0 start: {dateTime: '2022-01-08T13:00:00+11:00', timeZone: 'Australia/Sydney'} status: 'confirmed' summary: '' updated: '2022-01-04T08:09:10.933Z' [[Prototype]]: Object [[Prototype]]: Object length: 2 [[Prototype]]: Array(0) kind: 'calendar#events' nextSyncToken: 'CIjkzLfSl_UCEAAYASCvg6XIAQ==' summary: '' timeZone: 'Australia/Melbourne' updated: '2022-01-04T08:09:10.933Z' [[Prototype]]: Object
Upvotes: 4
Views: 488
Reputation: 6427
You can accomplish this using the Google Api Node.js Client in this manner:
Google Calendar Event Attendees | Run in Fusebit |
---|
const calendarClient = googleClient.calendar('v3');
// Update the below fields with your desired values
const calendarId = 'YOUR_CALENDAR_ID';
const eventId = 'YOUR EVENT_ID';
const response = await calendarClient.events.get({
calendarId,
eventId,
});
const attendees = response.data.attendees;
Upvotes: 2
Reputation: 648
for (var event of response['items']){}
Upvotes: 0