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.
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
Run
composer require fungio/google-calendar-bundle:dev-master
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = [
// ...
new Fungio\GoogleCalendarBundle\FungioGoogleCalendarBundle()
];
}
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"
<?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');