“If we always helped one another, no one would need luck.”
It’s Monday, and that means we’re back with another post aimed at helping you overcome some of the most commonly asked questions about the APIs we work with here at Kloudless. Every Monday, we will aim to help answer some of the more repeated inquiries into the world’s most popular APIs. Today, we will be turning to one of the industry’s top names when it comes to cloud calendar management: Google Calendar.
The easiest way to help users add an event to their Google Calendar is to generate an HTML element with the correct parameters in place. It is, however, deceptively difficult to find the correct information on the required parameters through the official documentation. The API itself has undergone many changes over the last few years, and as a result, the requirements have changed. Let’s take a minute to go over exactly what you need to easily allow users to add predetermined events to their calendar.
The base URL for Google Calendar is now:
Every parameter that defines the details of your event will follow this base URL with some required query parameters. The list of params are as follows:
- text (this is the name of the event)
- dates (ISO date format, startdate/enddate – you musthave both a start and end time) The criteria for the dates are:
an event with start/end times looks like so: 20190920T160000/20190920T180000
for all-day events, the end date must be +1 day to whatever you want to end date to be, like so: you can use 20190920/20190921
- ctz (this is a timezone such as America/New_York) You can leave this param blank to use the user’s default timezone. It is highly recommended that you include this in almost all situations, though. For example, in the case of sending out a reminder for a video conference, if three people in different timezones clicked this link and set a reminder for their “own” Tuesday at 10:00 am, they will all have an event set to their own timezone, which means they’ll all have a pretty lonely meeting.)
- details (This is a URL encoded event description and details)
- location (This is a URL encoded location of the event. Make sure it’s an address google maps can parse accordingly.)
- add (This is a comma-separated list of emails that adds guests to your new event)
Keep in mind that the API accepts
+ for spaces in addition to
%20, and if you are using PHP, both urlencode and rawencode will work.
After you’ve compiled all of your required params, your <a href> should look something like this:
That’s all there is to it! We’d love to hear from you on any API questions you may want us to answer in the future, so please send any requests to firstname.lastname@example.org.