Back

Sample Google Calendar API fetch

Description

A working copy of a JSON fetch from the Google Calendar API.

 

The most useful resource/page I found was here - it allows you to generate the JSON query - keep scrolling, the tool is at the bottom of the page:
https://developers.google.com/google-apps/calendar/v3/reference/events/list#examples
 
You will need to use the CalendarID (from the calendar page), and you will need your own API Key:
https://developers.google.com/google-apps/calendar/firstapp

 

 

Code

#set ($RSTdate=$date.get('yyyy-MM-dd'))
#set ($RSTdate=$RSTdate+"T05:00:00.000-04:00")
#set ($usedate=$UtilMethods.encodeURL($RSTdate))
##Need the date in RST3339 timestamp


#set($myjson = $json.fetch("https://www.googleapis.com/calendar/v3/calendars/m.marywood.edu_f5qiptk2okvpe4m1mt43hmhegg%40group.calendar.google.com/events?maxResults=5&timeMin=${usedate}&key={redacted for security reasons-get your own API code}"))


#foreach ($item in $myjson.get("items"))

 $item.get("summary")  || $item.get("start")<br>

#end