Skip to content

fungio/FungioGoogleCalendarBundle

Repository files navigation

Google Calendar Bundle

This bundle use Google API for list, create, or update events in Google Calendar.

Please feel free to contribute, to fork, to send merge request and to create ticket.

Requirement

Create a API account

Go to the developers console : https://console.developers.google.com

Create an oauth ID. Do not forget the redirect Uri.

Click on "Download JSON" to get your client_secret.json

Installation

Step 1: Install GoogleCalendarBundle

Run

composer require fungio/google-calendar-bundle:dev-master

Step 2: Enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Fungio\GoogleCalendarBundle\FungioGoogleCalendarBundle()
    ];
}

Step 3: Configuration

Copy your client_secret.json file for example in app/Resources/GoogleCalendarBundle/client_secret.json

# app/config/parameters.yml

fungio_google_calendar:
    google_calendar:
        application_name: "Google Calendar"
        credentials_path: "%kernel.root_dir%/.credentials/calendar.json"
        client_secret_path: "%kernel.root_dir%/Resources/GoogleCalendarBundle/client_secret.json"

Example

<?php
// in a controller
$request = $this->get('request_stack')->getMasterRequest();

$googleCalendar = $this->get('fungio.google_calendar');
$googleCalendar->setRedirectUri($redirectUri);

if ($request->query->has('code') && $request->get('code')) {
    $client = $googleCalendar->getClient($request->get('code'));
} else {
    $client = $googleCalendar->getClient();
}

if (is_string($client)) {
    return new RedirectResponse($client);
}

$events = $googleCalendar->getEventsForDate('primary', new \DateTime('now');

About

Google Calendar Bundle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages