API::Google::GCal - Google Calendar API client
version 0.12
use API::Google::GCal; my $gapi = API::Google::GCal->new({ tokensfile => 'config.json' }); my $user = 'someuser@gmail.com'; my $calendar_id = 'ooqfhagr1a91u1510ffdf7vfpk@group.calendar.google.com'; my $timeZone = 'Europe/Moscow'; my $event_start = DateTime->now->set_time_zone($timeZone); my $event_end = DateTime->now->add_duration( DateTime::Duration->new( hours => 2) ); $gapi->refresh_access_token_silent($user); # inherits from API::Google $gapi->get_calendars($user); $gapi->get_calendars($user, ['id', 'summary']); # return only specified fields $gapi->get_calendar_id_by_name($user, 'Contacts'); my $event_data = {}; $event_data->{summary} = 'Exibition'; $event_data->{description} = 'Amazing cats exibition'; $event_data->{location} = 'Angels av. 13'; $event_data->{start}{dateTime} = DateTime::Format::RFC3339->format_datetime($event_start); # '2016-11-11T09:00:00+03:00' format $event_data->{end}{dateTime} = DateTime::Format::RFC3339->format_datetime($event_end); $event_data->{start}{timeZone} = $event_data->{end}{timeZone} = $timeZone; # not obligatory $gapi->add_event($user, $calendar_id, $event_data); my $freebusy_data = { user => $user, calendarId => $calendar_id, dt_start => DateTime::Format::RFC3339->format_datetime($event_start), dt_end => DateTime::Format::RFC3339->format_datetime($event_end), timeZone => 'Europe/Moscow' }; $gapi->busy_time_ranges($freebusy_data); $gapi->events_list($freebusy_data);
Get all calendars of particular Google account
$gapi->get_calendar_id_by_name($user, $name)
Get calendar id by its name. Name = "summary" parameter
$gapi->add_event($user, $calendar_id, $event_data)
# https://developers.google.com/google-apps/calendar/v3/reference/events/insert
Return List of time ranges during which this calendar should be regarded as busy.
Return list of events in particular calendar
https://developers.google.com/google-apps/calendar/v3/reference/events/list
Usage:
$gapi->events_list({ calendarId => 'ooqfhagr1a91u1510ffdf7vfpk@group.calendar.google.com', user => 'someuser@gmail.com' });
Pavel Serikov <pavelsr@cpan.org>
This software is copyright (c) 2016 by Pavel Serikov.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install API::Google, copy and paste the appropriate command in to your terminal.
cpanm
cpanm API::Google
CPAN shell
perl -MCPAN -e shell install API::Google
For more information on module installation, please visit the detailed CPAN module installation guide.