jlbousing / google-calendar-event
Package to make a google calendar event by any PHP project
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jlbousing/google-calendar-event
Requires
- php: ^7.4|^8.0
- google/apiclient: ^2.16
This package is auto-updated.
Last update: 2025-12-02 17:58:08 UTC
README
PHP package to create Google Calendar events from any PHP project.
Installation
composer require jlbousing/google-calendar-event
Example of use with a Laravel API
https://github.com/jlbousing/laravel-google-calendar-example
Configuration
This package requires Google Calendar API credentials. Follow these steps to obtain them:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Calendar API
- Create OAuth 2.0 credentials and obtain your Client ID, Client Secret, and configure your redirect URI
- Save these credentials to use in your project
Usage
Initialization
<?php require_once 'vendor/autoload.php'; use Jlbousing\GoogleCalendar\GoogleCalendar; // Configuration $config = [ 'app_name' => 'Your Application Name', 'client_id' => 'your-client-id-here', 'client_secret' => 'your-client-secret-here', 'redirect_uri' => 'https://your-redirect-uri.com', ]; // Initialize $googleCalendar = new GoogleCalendar($config);
Authentication
The package uses OAuth 2.0 for authentication. First, you need to generate an authentication URL and then obtain an access token:
// Generate authentication URL $authUrl = $googleCalendar->auth(); echo "Open this URL in your browser: " . $authUrl; // After authorizing, you'll receive a code that you must use to obtain the token $code = 'authorization-code-received'; $token = $googleCalendar->getToken($code); // Save this token for future requests
Refresh an expired token
$newToken = $googleCalendar->refreshToken($token);
List calendars
$calendars = $googleCalendar->listCalendars($token); foreach ($calendars as $calendar) { echo "Calendar: " . $calendar->getSummary() . " - ID: " . $calendar->getId() . "\n"; }
Create an event
use Jlbousing\GoogleCalendar\DTOs\EventDTO; // Using the EventDTO class $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary') ->setTitle('Important Meeting') ->setDescription('Discuss the new project') ->setStart('2023-04-15T09:00:00-05:00') ->setEnd('2023-04-15T10:00:00-05:00') ->setTimezone('America/New_York') ->setLocation('Conference Room A') ->addAttendee('colleague@example.com') ->addAttendee('manager@example.com', true) // true = optional ->setSendNotifications(true) ->setCreateMeet(true); // Create a Google Meet session $event = $googleCalendar->createEvent($eventDTO, $token); echo "Event created with ID: " . $event->getId(); echo "Meet link: " . $event->getHangoutLink(); // Get the Google Meet link
Create an event with Google Meet
To create an event with a Google Meet session, simply set the createMeet property to true in your EventDTO:
$eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary') ->setTitle('Virtual Meeting') ->setDescription('Online team meeting') ->setStart('2023-04-15T09:00:00-05:00') ->setEnd('2023-04-15T10:00:00-05:00') ->setTimezone('America/New_York') ->setCreateMeet(true); // This will create a Google Meet session $event = $googleCalendar->createEvent($eventDTO, $token); // Get the Meet link $meetLink = $event->getHangoutLink(); echo "Google Meet link: " . $meetLink;
The Google Meet link will be automatically included in the event details and sent to all attendees if notifications are enabled.
Create an event with Google Meet recording
To create an event with Google Meet recording that saves to Drive, use the setRecordMeet() and setSaveToDrive() methods:
$eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary') ->setTitle('Recorded Virtual Meeting') ->setDescription('This meeting will be recorded') ->setStart('2023-04-15T09:00:00-05:00') ->setEnd('2023-04-15T10:00:00-05:00') ->setTimezone('America/New_York') ->setCreateMeet(true) ->setRecordMeet(true) // Enable recording ->setSaveToDrive(true); // Save recording to Google Drive $event = $googleCalendar->createEvent($eventDTO, $token); // Get the Meet link $meetLink = $event->getHangoutLink(); echo "Google Meet link: " . $meetLink;
Create an event with advanced Google Meet features
The package now supports the latest Google Meet API features including automatic recording, transcription, and note-taking:
$eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary') ->setTitle('Advanced Virtual Meeting') ->setDescription('Meeting with all advanced features') ->setStart('2023-04-15T09:00:00-05:00') ->setEnd('2023-04-15T10:00:00-05:00') ->setTimezone('America/New_York') ->setCreateMeet(true) ->setAutoRecord(true) // Automatic recording ->setAutoTranscription(true) // Automatic transcription ->setTakeNotes(true) // Automatic note-taking ->setSaveToDrive(true); // Save all artifacts to Drive $event = $googleCalendar->createEvent($eventDTO, $token);
Available advanced features:
setAutoRecord(true): Enables automatic recording (requires Google Workspace)setAutoTranscription(true): Enables automatic transcriptionsetTakeNotes(true): Enables automatic note-taking ("Take notes for me")setSaveToDrive(true): Saves all artifacts (recordings, transcriptions, notes) to Google Drive
Note: Advanced features require a Google Workspace account (Business Standard, Business Plus, Enterprise, or Education). Some features may need to be enabled in your Google Workspace admin console.
Get Meet recordings from Drive
Retrieve all Meet recordings stored in Google Drive:
// Get all recordings from the default "Meet Recordings" folder $recordings = $googleCalendar->getMeetRecordings($token); // Or specify a custom folder name and max results $recordings = $googleCalendar->getMeetRecordings($token, 'My Recordings', 100); foreach ($recordings as $recording) { echo "Recording: " . $recording['name'] . "\n"; echo "Created: " . $recording['createdTime'] . "\n"; echo "Size: " . ($recording['size'] ? number_format($recording['size'] / 1024 / 1024, 2) . " MB" : "N/A") . "\n"; echo "View Link: " . $recording['webViewLink'] . "\n\n"; }
Get recordings for a specific event
Retrieve recordings associated with a specific calendar event:
use Jlbousing\GoogleCalendar\DTOs\EventDTO; $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary'); $eventId = 'EVENT_ID'; $recordings = $googleCalendar->getEventRecordings($eventDTO, $eventId, $token); if (!empty($recordings)) { foreach ($recordings as $recording) { echo "Recording: " . $recording['name'] . "\n"; echo "Link: " . $recording['webViewLink'] . "\n"; } } else { echo "No recordings found for this event."; }
Download a Meet recording
Download a recording file from Google Drive:
$fileId = 'DRIVE_FILE_ID'; // Download and save to a file $result = $googleCalendar->downloadRecording($fileId, $token, '/path/to/save/recording.mp4'); if ($result['success']) { echo "Recording saved to: " . $result['path'] . "\n"; echo "File: " . $result['file']['name'] . "\n"; } // Or get the content directly $content = $googleCalendar->downloadRecording($fileId, $token); // Process the content as needed
Get Meet transcriptions
Retrieve transcriptions from Google Meet recordings:
// Get all transcriptions from the default "Meet Recordings" folder $transcriptions = $googleCalendar->getMeetTranscriptions($token); // Or specify a custom folder name and max results $transcriptions = $googleCalendar->getMeetTranscriptions($token, 'My Recordings', 100); foreach ($transcriptions as $transcription) { echo "Transcription: " . $transcription['name'] . "\n"; echo "Created: " . $transcription['createdTime'] . "\n"; echo "View Link: " . $transcription['webViewLink'] . "\n\n"; } // Get transcription for a specific event $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary'); $transcriptions = $googleCalendar->getEventTranscription($eventDTO, 'EVENT_ID', $token);
Get Meet notes
Retrieve notes generated by Google Meet's "Take notes for me" feature:
// Get all notes from the default "Meet Recordings" folder $notes = $googleCalendar->getMeetNotes($token); // Or specify a custom folder name and max results $notes = $googleCalendar->getMeetNotes($token, 'My Recordings', 100); foreach ($notes as $note) { echo "Note: " . $note['name'] . "\n"; echo "Created: " . $note['createdTime'] . "\n"; echo "View Link: " . $note['webViewLink'] . "\n\n"; } // Get notes for a specific event $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary'); $notes = $googleCalendar->getEventNotes($eventDTO, 'EVENT_ID', $token);
Get all Meet artifacts
Retrieve all artifacts (recordings, transcriptions, and notes) at once:
$artifacts = $googleCalendar->getAllMeetArtifacts($token, 'Meet Recordings', 50); echo "Recordings: " . count($artifacts['recordings']) . "\n"; echo "Transcriptions: " . count($artifacts['transcriptions']) . "\n"; echo "Notes: " . count($artifacts['notes']) . "\n"; // Access each type foreach ($artifacts['recordings'] as $recording) { echo "Recording: " . $recording['name'] . "\n"; } foreach ($artifacts['transcriptions'] as $transcription) { echo "Transcription: " . $transcription['name'] . "\n"; } foreach ($artifacts['notes'] as $note) { echo "Note: " . $note['name'] . "\n"; }
Get event details
use Jlbousing\GoogleCalendar\DTOs\EventDTO; $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary'); $eventId = 'EVENT_ID'; $event = $googleCalendar->getEvent($eventDTO, $eventId, $token); echo "Event title: " . $event->getSummary();
Update an event
use Jlbousing\GoogleCalendar\DTOs\EventDTO; $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary') ->setTitle('Updated Meeting') ->setDescription('New event description') ->setStart('2023-04-15T10:00:00-05:00') ->setEnd('2023-04-15T11:00:00-05:00') ->setLocation('New Location') ->setSendNotifications(true); $eventId = 'EVENT_ID'; $updatedEvent = $googleCalendar->updateEvent($eventDTO, $eventId, $token); echo "Event updated: " . $updatedEvent->getSummary();
Delete an event
use Jlbousing\GoogleCalendar\DTOs\EventDTO; $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary'); $eventId = 'EVENT_ID'; $result = $googleCalendar->deleteEvent($eventDTO, $eventId, $token); if ($result) { echo "Event successfully deleted"; }
List events
use Jlbousing\GoogleCalendar\DTOs\EventDTO; $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary'); $events = $googleCalendar->listEvents($eventDTO, $token); $items = $events->getItems(); foreach ($items as $event) { echo "Event: " . $event->getSummary() . " - Date: " . $event->getStart()->getDateTime() . "\n"; }
List events by date
use Jlbousing\GoogleCalendar\DTOs\EventDTO; $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary'); $events = $googleCalendar->listEventsByDate($eventDTO, $token); $items = $events->getItems(); foreach ($items as $event) { echo "Event: " . $event->getSummary() . " - Date: " . $event->getStart()->getDateTime() . "\n"; }
Data Transfer Objects (DTOs)
This package uses DTOs to handle data in a structured way:
ConfigDTO
Handles the configuration for the Google Calendar client:
use Jlbousing\GoogleCalendar\DTOs\ConfigDTO; $configDTO = new ConfigDTO([ 'app_name' => 'Your Application Name', 'client_id' => 'your-client-id', 'client_secret' => 'your-client-secret', 'redirect_uri' => 'https://your-redirect-uri.com', ]);
EventDTO
Handles event data:
use Jlbousing\GoogleCalendar\DTOs\EventDTO; // Create manually $eventDTO = new EventDTO(); $eventDTO->setCalendarId('primary') ->setTitle('Important Meeting') ->setDescription('Discuss the new project') ->setStart('2023-04-15T09:00:00-05:00') ->setEnd('2023-04-15T10:00:00-05:00') ->setTimezone('America/New_York') ->setLocation('Conference Room A') ->addAttendee('colleague@example.com') ->addAttendee('manager@example.com', true) ->setSendNotifications(true); // Or create from an array $eventDTO = EventDTO::fromArray([ 'calendar_id' => 'primary', 'title' => 'Important Meeting', 'description' => 'Discuss the new project', 'start' => '2023-04-15T09:00:00-05:00', 'end' => '2023-04-15T10:00:00-05:00', 'timezone' => 'America/New_York', 'location' => 'Conference Room A', 'attendees' => [ ['email' => 'colleague@example.com'], ['email' => 'manager@example.com', 'optional' => true] ], 'send_notifications' => true, 'create_meet' => true, 'record_meet' => true, 'save_to_drive' => true, 'auto_record' => true, 'auto_transcription' => true, 'take_notes' => true ]);
Google Meet Recording Features
Requirements for Recording
- Google Workspace Account: Recording is only available for Google Workspace accounts (Business Standard, Business Plus, Enterprise, or Education editions)
- Permissions: The user must have recording permissions enabled in their Google Workspace account
- Drive Access: The package requires Drive API scopes to access recordings stored in Google Drive
How Recording Works
- When you create an event with
setRecordMeet(true), the event is configured to support recording - During the meeting, an authorized participant must manually start the recording from the Meet interface
- Once the recording is stopped, it is automatically saved to Google Drive in the "Meet Recordings" folder
- You can then retrieve the recordings using the methods provided in this package
API Scopes
The package automatically includes the following API scopes:
Calendar API:
https://www.googleapis.com/auth/calendar- Full calendar accesshttps://www.googleapis.com/auth/calendar.readonly- Read-only calendar accesshttps://www.googleapis.com/auth/calendar.events- Full event accesshttps://www.googleapis.com/auth/calendar.events.readonly- Read-only event access
Drive API:
https://www.googleapis.com/auth/drive.readonly- Read access to Drive fileshttps://www.googleapis.com/auth/drive.file- Access to files created by the apphttps://www.googleapis.com/auth/drive.meet.readonly- NEW: Access to Google Meet artifacts (recordings, transcriptions, notes)
Meet API:
https://www.googleapis.com/auth/meetings.space.created- Create meeting spaceshttps://www.googleapis.com/auth/meetings.space.readonly- Read meeting spaces
Important: Make sure to re-authenticate your application after adding these scopes to get the necessary permissions. The new drive.meet.readonly scope is essential for accessing Meet artifacts.
Requirements
- PHP 7.4 or higher (PHP 8.0+ recommended for latest features)
- PHP cURL extension enabled
- Google account with Calendar API enabled
- Google Drive API enabled (for recording features)
- Google Workspace account (for recording functionality)
License
MIT