<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ginnie Hench on Medium]]></title>
        <description><![CDATA[Stories by Ginnie Hench on Medium]]></description>
        <link>https://medium.com/@engineniches?source=rss-5676f81193fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Ya7bThcUlF2NNKnn.jpeg</url>
            <title>Stories by Ginnie Hench on Medium</title>
            <link>https://medium.com/@engineniches?source=rss-5676f81193fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:22:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@engineniches/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Integrating Google Calendar with FullCalendar.JS into a SilverStripe 4 app]]></title>
            <link>https://medium.com/@engineniches/integrating-google-calendar-with-fullcalendar-js-into-a-silverstripe-4-app-88667fafec7a?source=rss-5676f81193fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/88667fafec7a</guid>
            <category><![CDATA[google-calendar]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[silverstripe]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[fullcalendar]]></category>
            <dc:creator><![CDATA[Ginnie Hench]]></dc:creator>
            <pubDate>Mon, 29 Oct 2018 01:44:54 GMT</pubDate>
            <atom:updated>2018-10-29T01:57:09.691Z</atom:updated>
            <content:encoded><![CDATA[<h3>Displaying Google Calendar Events in a SilverStripe 4 app with FullCalendar</h3><p>This post walks through the steps I took to display event data accessed through the Google Calendar API in a PHP/SilverStripe website using the FullCalendar jQuery plugin, along with a few extra custom JS functions.</p><p>I’m writing this post in October, 2018 and using the following:</p><ul><li><a href="https://www.silverstripe.org/">SilverStripe</a>: silverstripe/recipe-cms”: “4.2.1@stable</li><li><a href="https://developers.google.com/api-client-library/">Google Client</a>: &quot;google/apiclient&quot;: &quot;^2.0&quot;</li><li><a href="https://developers.google.com/calendar/">Google Calendar API</a> version 3</li><li><a href="https://fullcalendar.io/">FullCalendar</a> v3.9.0</li></ul><p>While making use of the most basic features of the tools listed above, I used a <a href="https://developers.google.com/api-client-library/php/auth/service-accounts#creatinganaccount">Google Service account</a> rather than setting up a token to establish API credentials. To enhance the user’s experience, I wrote some additional JavaScript functions to organize the event details to display in pop-up modal whenever the user clicks a calendar event.</p><p>In my web app, I need all site visitors to see calendar events pulled from a single Google calendar that is owned by the same people who manage our website’s content management system. I wanted to store the Google Account credentials on the backend and there was no need to send requests for info from Google Calendars belonging to website visitors.</p><p>A Google Service account is the preferred way to set up the credentials I needed. I used the <a href="https://developers.google.com/calendar/quickstart/php">Google Calendar API PHP Quickstart Guide</a> to familiarize myself with the API methods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kBSXXn--hHbCXaVjL3Zig.png" /><figcaption>Copy of instructions on the Google Calendar PHP Quickstart Guide</figcaption></figure><p><strong>The guide didn’t cover service accounts, so I skipped parts b and c under Step 1 above and downloaded a key for a new service account, as outlined below.</strong></p><p>Initially, I had trouble finding info on setting up a Service Account because I was using an outdated guide with a broken link. The screenshots below illustrate steps necessary to create a Service Account for an existing Google project and how to get the JSON-formatted private key, which is required for setting up a new Google Client instance. <em>Some of these details may change if Google makes updates to their API and/or Developer’s console interface.</em></p><p><strong>Once you have the JSON key for the service account, keep it somewhere safe so you know where to find it when you need it and keep it out of version control (GitHub, GitLab, etc).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lYeWnlMsI0hXwSXe3KXkWg.png" /><figcaption>Step 1: Click triple bar icon to reveal API menu; Steps 2/3: Click “IAM &amp; admin” to access “Service accounts”; Step 4: Create a Service Account for your existing Google Project; Step 5: To generate a JSON-formatted credential key, click the verticle triple-dot icon under Actions and select “Create key”; Step 6: Leave the default JSON formatted value set and click “Create”; Step 7: Once the key has downloaded, move it to a secure location that can be accessed by your app. If you keep the key within your app directory, add it to your `.gitignore` file or use another appropriate method to exclude the file from your version control system.</figcaption></figure><p>The private key for a service account will have fields similar to what is shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78a3f1cdaba7d859ae95f972133e9bfc/href">https://medium.com/media/78a3f1cdaba7d859ae95f972133e9bfc/href</a></iframe><p>The other important property to collect from the service account is the <strong>client_email </strong>address. Go to the Google Calendar that you’ll be sending requests to. Go to Settings and navigate to the “Share with specific people” section. Add the Service Account client_email to this section and assign permission to “Make changes and manage sharing”. This setting allows you to collect event color_id’s from the API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zrSpBaGJ7GEl1DcyyGDpCQ.png" /></figure><p>While visiting your Google Calendar settings, you can collect your <strong>calendar’s ID</strong> under the <strong>Integrate calendar</strong> section. You’ll assign this value to the $calendarId variable within the getEvents function in the CalendarController.php code below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vdS4MLbLxJ51I5Nb2-b2UQ.png" /><figcaption>Copy of step 2 in the Google Calendar PHP Quickstart Guide</figcaption></figure><p><a href="https://developers.google.com/calendar/quickstart/php#step_3_set_up_the_sample">Step 3 in the Quickstart Guide</a> provides a PHP script that works as a command line app, which differed from what I wanted to do in the following ways:</p><ul><li>I’m building a web app, so I don’t need the conditional Exception for a command line app</li><li>I wrote the functions for the Google Calendar API requests within a Controller that lives in the app/src directory, consistent with SilverStripe convention.</li><li>I don’t want to rely on access tokens that might expire, so there is no need for code that creates a token, nor checks on whether a token is still valid.</li><li>Since I’ll be rendering the calendar events data using the <a href="https://fullcalendar.io/">FullCalendar JavaScript library</a>, my Controller needs to pass the data I get from the Google Calendar API to my view template as JSON.</li></ul><p>You’ll need the following PHP files to retrieve your calendar events from the Google Calendar API. You don’t have to create a unique class for the GoogleClient, but I wanted to because I may need to create other Google Service instances in my web app soon.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e62df2f78b0ab68718c0fd60735e2bcf/href">https://medium.com/media/e62df2f78b0ab68718c0fd60735e2bcf/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d1a6538b1ff40f3e89c2b93555f2c16/href">https://medium.com/media/0d1a6538b1ff40f3e89c2b93555f2c16/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5330c72faf8b6009462b67820509b9f/href">https://medium.com/media/d5330c72faf8b6009462b67820509b9f/href</a></iframe><p>The Calendar page template includes 2 divs that hold data passed from the PHP backend via the data properties. The JavaScript functions below access the elements and the data in the template based on the id tags and their respective data properties.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bef87451aa40ec8d3a5c00a3cc276bc8/href">https://medium.com/media/bef87451aa40ec8d3a5c00a3cc276bc8/href</a></iframe><p>The following jQuery/JavaScript functions serve to access data passed to the *.ss template from the Controller and display that data using the FullCalender.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53cbe7a8ac8d5e53818e65bdf93c406b/href">https://medium.com/media/53cbe7a8ac8d5e53818e65bdf93c406b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88667fafec7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>