[insert_php] session_start(); include_once(ABSPATH . ‘google-api/vendor/autoload.php’); $client = new Google_Client(); $client->setAuthConfig(‘wp-content/client_secret.json’); $client->addScope(Google_Service_Calendar::CALENDAR_READONLY); if (isset($_SESSION[‘access_token’]) && $_SESSION[‘access_token’]) { $client->setAccessToken($_SESSION[‘access_token’]); $service = new Google_Service_Calendar($client); // Print the next 10 events on the user’s calendar. $calendarId = ‘4l1thd51upoe433ssodllmm71c@group.calendar.google.com’; $optParams = array( ‘maxResults’ => 10, ‘orderBy’ => ‘startTime’, ‘singleEvents’ => TRUE, ‘timeMin’ => ‘2017-10-19T00:00:00+01:00’, ); $results = $service->events->listEvents($calendarId, $optParams); if (count($results->getItems()) == 0) { print “No upcoming events found.\n”; } else { print “Upcoming events:\n”; foreach ($results->getItems() as $event) { $start = $event->start->dateTime; if (empty($start)) { $start = $event->start->date; } printf(“%s (%s)\n”, $event->getSummary(), $start); } } } else { $redirect_uri = ‘http://professionalmaids.co.uk/oauth2callback’; header(‘Location: ‘ . filter_var($redirect_uri, FILTER_SANITIZE_URL)); } [/insert_php]