I was trying to get the number of events that a specific user created in the past month using Google Calendar API.
The problem is that I got all the events where a user was invited. I don't see how to query only the events that user created.
calendarId: user's email adress updatedMin : today - one month
I am using Google's api explorer to query Calendar API.
You can filter them by creator.email
or organizer.email
function getCreatedEvents() {
var user = '[email protected]';
var today = new Date();
var date = new Date();
date.setMonth(date.getMonth() - 1);
var args = {
timeMin: new Date(date.getTime()).toISOString(),
timeMax: new Date(today.getTime()).toISOString()
}
var events = Calendar.Events.list(user, args).items;
events.forEach(function (event){
if(event.creator && event.creator.email == user){
// do something to events
Logger.log(event);
}
});
}
Include a query parameter in your request:
q: [email protected]
This will filter to only events organized by [email protected].
Updated:
Unfortunately the query parameter does not accept key value pairs. This solution will not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With