Use Google Calendar API to find next available time slot

Viewed 1611

I'm trying to create a function that will perform the following leveraging Google Calendar API:

  • Find the next 30-minute calendar slot within a given parameter of days, start times, and end times
  • Schedule a meeting for this task with supplied meeting info

I'm having a hard time finding good documentation for a process like this leveraging PHP / Javascript, and I was hoping someone might be able to point me in the right direction or help me get the ball rolling.

1 Answers

The Google Calendar API has a list endpoint to return all events with a given calenarId (and optionally within a range of dates). Assuming that you have the OAuth of the user for the calendar that you want to access, use it to call the endpoint and the rest is writing a script to get the current time and comparing it with the calendar events to find the nearest 30-minute timeslot.

There is also an insert endpoint for adding events.

Related