fbizi / google-meet
包含会议功能的Google日历事件
1.1.1
2023-08-22 21:08 UTC
Requires
- php: >=7.4
Requires (Dev)
- enlightn/security-checker: ^1.9
- overtrue/phplint: ^3.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
README
轻量级Google日历API库,用于管理Google日历上的事件。您可以创建带有视频会议(Google Meet)的事件,更新和取消。该库仅关注日历事件资源。
安装
该包可在 Packagist 上找到,您可以使用Composer进行安装。
composer require fbizi/google-meet
依赖项
- PHP 7.4+
基本用法
在使用此库之前,请确保已在Google Cloud Console上注册Google应用程序并启用日历API,以便您可以进行API调用。如果您还没有,请遵循此 指南。
use FBIZI\Calendar\GoogleCalendar; $calendar = new GoogleCalendar(CLIENT_ID, CLIENT_REDIRECT_URL, CLIENT_SECRET); // Generate authenticate url link so you can call it $url = GoogleCalendar::auth(string $client_redirect_url, string $client_id, string $access_type optional, bool $redirect optional); // check if get the response code after calling the authentication url if(isset($_GET['code']) && !empty($_GET['code'])){ $code = $_GET['code']; $calendar->getAccessToken($code); // if you want to save the token and refresh_token somewhere for use later e.g DB just call this $token_to_save = $calendar->token; $refresh_token_to_save = $calendar->refresh_token; // if want to assign saved token and refresh_token just do this $calendar->token = $token_to_save; $calendar->refresh_token = $refresh_token_to_save; // for event creation $timezone = $calendar->getCalendarTimezone(); // to get user calendar timezone $args = [ "title" => "Event title", // optional "description" => "Event description", // optional "start" => [ "dateTime" => "2024-12-31T12:00:00", "timeZone" => $timezone['value'] ], "end" => [ "dateTime" => "2024-12-31T13:00:00", "timeZone" => $timezone['value'], ], "attendees" => [ ["email" => "test1@test.com"] ], "meet_id" => "jdjhjdhdjdj", // optional ]; $event = GoogleCalendar::eventData(array $args); $data = $calendar->createEvent(array $event, string $calendar_id optional); // on successful will get the event resource // retrive event id or meet link $data['id'] | $data['hangoutLink'] // for event update $timezone = $calendar->getCalendarTimezone(); // to get user calendar timezone $args['attendees'] = [ ["email" => "test1@test.com"], ["email" => "test2@test.com"] // add 1 more attendee ]; $event_id = $data['id']; $event = GoogleCalendar::eventData(array $args); $data = $calendar->updateEvent(string $event_id, array $event, string $calendar_id optional); // on successful will get the event resource // for event cancellation $calendar->cancelEvent($data['id']); // explore other methods such as get event or calendar by id }
捐赠
方式
如果这个项目帮助您节省了开发时间,您可以通过请我喝杯咖啡来支持我:)