How To Implement Google Calendar Events Listing to Drupal Site ?
In a previous Responsive Web Solution developers blog post, I discussed How to Embed Google calendar in Drupal site. In this post we'll cover an alternative method in displaying listing of Events to our Drupal site. For this we are going to use GCal Events Module which will display a block of upcoming events from Google Calendar by using Google Calendar API v3.
Step 1: Enable GCal Events Module
Download GCal Events Module and extract it to sites/all/module and then enable it. Once you enable this module you will get "GCal Events [Block 1]" in adminstration/structure/block page.
Step 2: Configure GCal Events Module
To use this module you must configure it with Google Calendar. So you need to create Google Developer ID key (if you have not) and Google API Client Library for PHP.
Get a Google Developer ID key:
- Navigate to https://code.google.com/apis/console.
- Create a project and turn on the Calendar API (agree to the TOS).
- Navigate to "Credentials" in the left menu under "APIs & auth".
- Create a new key (server key) if you don't already have one.
- Once it's created, it'll display on that page. Copy the "API KEY" and save it for later.
Get the Google API Client Library for PHP:
- Navigate to https://github.com/google/google-api-php-client and clone the master branch.
- Rename that cloned directory "google-api-php-client" and move it to sites/all/libraries.
Step 3: Configure your GCal Events blocks
- In the module configuration page(admin/config/content/gcal_events), set the number of blocks to display.
- Configure GCal Events [Block 1] in adminstration/structure/block
- Put the API Key you created into the "Developer ID" field.
- Get the Calendar ID and Private Key from Google Calendar and input as the calendar ID and Private ID.
- Set the block to an active region and save.
How to get Google Calendar ID:
- Log into your Google Calendar.
- Click on the "Settings" tab.
- Select "Calendars"
- Click on the calendar you want to use.
- In the section labeled "Calendar Address", you should see "Calendar ID". Copy and paste that ID. into the GCal Events configuration.
If you just fill in the Calendar ID, GCal Events will default to using your public calendar. Events marked as private will not show up. If you want to display your private calendar (not advised):
- Under the section marked "Private Address", click on XML
- http://www.google.com/calendar/feeds/[ Celendar ID ]/private-[PRIVATE ID ]/basic
- For Private ID, you are looking for the section between "private-" and "/basic"