Sample Google Calendar API fetch


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:
You will need to use the CalendarID (from the calendar page), and you will need your own API Key:




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

${esc.hash}set(${esc.dollar}myjson = ${esc.dollar}json.fetch("${esc.dollar}{usedate}&key={redacted for security reasons-get your own API code}"))

${esc.hash}foreach (${esc.dollar}item in ${esc.dollar}myjson.get("items"))

 ${esc.dollar}item.get("summary")  || ${esc.dollar}item.get("start")<br>


Have you created code you'd like to share with the dotCMS community?

Share your code Become a Contributor