Integration with Google Calendar
Download the package here.
In this chapter you'll find out, how to keep Scheduler and Google Calendar in sync.
Note, that the sync is 2-way, i.e. any changes you make to events in either Scheduler or Google Calendar will be reflected in both applications.
- If you alter the same event in both applications, the latest update will be synced between Scheduler and Google Calendar.
- If you delete an event in one of the calendars, this event will be deleted from both applications.
- You sync Scheduler with the primary Google Calendar. Events from the secondary calendars won't be synced.
- Note, you sync all the events, containing in both Google Calendar and Scheduler, at once. You can't sync just some specific part of events.
- By default, Scheduler takes the text and duration (start and end times) of the Google Calendar event. If you need, you can get additional information of the event. See the details below.
To start the integration, do the following preparations:
- Login to the Google API console - https://console.cloud.google.com/cloud-resource-manager.
- Click on the "Create new project" button. The "Google apis" screen opens.
- Enable the "Calendar API" service in the "Services" tab.
- Go to the "API Access" tab and click on "Create an OAuth2.0 Client ID" button. The "Create Client ID" form opens.
- Fill in the form and click the "Next" button. The next screen of the form opens.
- Select the "Service account" option and click on the "Create client ID" button. As a result, you will have the private key file, Client ID and Email address - they will be necessary later.
- Login to Google Calendar, which you want to use for the app, and share it on the Email address, which was used for login to the Google API console (step 1).
- Locate and save the calendar id (location of the calendar's id - https://drupal.org/node/589310).
- Create a php file with the name "data.php" with the code as in:
$calendar = new GoogleCalendarProxy(
- <account> - the "Email address", which was used for login to the Google API console.
- <key> - the path to your private key
- <calendar_id> - the calendar's id (can be taken from the settings of your Google Calendar account)
1. Open the HTML file containing the initialized scheduler or initialize one in a standard way (see details in the How to Start article.
2. Load Google Calendar's events to the scheduler through the load method. The 1st parameter is the path to the 'data.php' file, the 2nd parameter - expected data format that should be 'json'.
3. Initialize dataProcessor, to provide 2-way sync (if you need the readonly access - ignore this code).
var dp = new dataProcessor("./data.php");
How to pass additional information related to the event
By default, the scheduler gets values of all Google Calendar fields, but processes only 4 of them. All other values are read-only.
There is the following mapping between Google Calendar and Scheduler:
Google Calendar -> Scheduler
- id -> id
- title -> text
- startTime -> start_date
- endTime -> end_date
To process some other properties, make changes in the "src/google_proxy.php" file, resided in the provided package
(link to download).
Back to top