如何使用 hangoutLink 创建 Google 日历事件(Google 见面)
How to create a Google calendar event with hangoutLink (Google meet)
我正在使用 spatie/laravel-google-calendar
包来创建有会议的活动,但它只创建没有会议的活动,我合并了 this commit
但是没用'still create event without meeting'。
这是 event.php
文件
的 createFromGoogleCalendarEvent
方法
public static function createFromGoogleCalendarEvent(Google_Service_Calendar_Event $googleEvent, $calendarId)
{
// this option are to create a conference and add a link to meet in event
$googleCalendar = static::getGoogleCalendar($calendarId);
$service = $googleCalendar->getService();
$conference = new \Google_Service_Calendar_ConferenceData();
$conferenceRequest = new \Google_Service_Calendar_CreateConferenceRequest();
$conferenceRequest->setRequestId('randomString123');
$conference->setCreateRequest($conferenceRequest);
$googleEvent->setConferenceData($conference);
$googleEvent = $service->events->patch($calendarId, $googleEvent->id, $googleEvent, ['conferenceDataVersion' => 1]);
$event = new static;
$event->googleEvent = $googleEvent;
$event->calendarId = $calendarId;
return $event;
}
这是我创建事件的代码
$event = new Spatie\GoogleCalendar\Event;
$event->name = 'A new event';
$event->description = 'Event description';
$event->startDateTime = Carbon\Carbon::now();
$event->endDateTime = Carbon\Carbon::now()->addHour();
$event->save();
这是我的回复
{
anyoneCanAddSelf: null,
attendeesOmitted: null,
colorId: null,
created: "2021-04-06T11:54:35.000Z",
description: "Event description",
endTimeUnspecified: null,
etag: ""3235420151680000"",
eventType: "default",
guestsCanInviteOthers: null,
guestsCanModify: null,
guestsCanSeeOtherGuests: null,
hangoutLink: null,
htmlLink: "https://www.google.com/calendar/event?eid=dXZyNHByamc0ZXNqbDkxajI5c3I0cWI3c28gZGxvcW45M2VoOWlsZm5lOWRjb2xodDY5aWtAZw",
iCalUID: "uvr4prjg4esjl91j29sr4qb7so@google.com",
id: "uvr4prjg4esjl91j29sr4qb7so",
kind: "calendar#event",
location: null,
locked: null,
privateCopy: null,
recurrence: null,
recurringEventId: null,
sequence: 0,
status: "confirmed",
summary: "A new event",
transparency: null,
updated: "2021-04-06T11:54:35.840Z",
visibility: null,
creator: {
displayName: null,
email: "mohamed-service-account@mohamed-project.iam.gserviceaccount.com",
id: null,
self: null
},
organizer: {
displayName: "Mohamed calendar",
email: "dloqn93eh9ilfne9dcolht69ik@group.calendar.google.com",
id: null,
self: true
},
start: {
date: null,
dateTime: "2021-04-06T13:54:35+02:00",
timeZone: null
},
end: {
date: null,
dateTime: "2021-04-06T14:54:35+02:00",
timeZone: null
},
reminders: {
useDefault: true
}
}
我通过将 service account
身份验证替换为 oauth
解决了这个问题。
我正在使用 spatie/laravel-google-calendar
包来创建有会议的活动,但它只创建没有会议的活动,我合并了 this commit
但是没用'still create event without meeting'。
这是 event.php
文件
createFromGoogleCalendarEvent
方法
public static function createFromGoogleCalendarEvent(Google_Service_Calendar_Event $googleEvent, $calendarId)
{
// this option are to create a conference and add a link to meet in event
$googleCalendar = static::getGoogleCalendar($calendarId);
$service = $googleCalendar->getService();
$conference = new \Google_Service_Calendar_ConferenceData();
$conferenceRequest = new \Google_Service_Calendar_CreateConferenceRequest();
$conferenceRequest->setRequestId('randomString123');
$conference->setCreateRequest($conferenceRequest);
$googleEvent->setConferenceData($conference);
$googleEvent = $service->events->patch($calendarId, $googleEvent->id, $googleEvent, ['conferenceDataVersion' => 1]);
$event = new static;
$event->googleEvent = $googleEvent;
$event->calendarId = $calendarId;
return $event;
}
这是我创建事件的代码
$event = new Spatie\GoogleCalendar\Event;
$event->name = 'A new event';
$event->description = 'Event description';
$event->startDateTime = Carbon\Carbon::now();
$event->endDateTime = Carbon\Carbon::now()->addHour();
$event->save();
这是我的回复
{
anyoneCanAddSelf: null,
attendeesOmitted: null,
colorId: null,
created: "2021-04-06T11:54:35.000Z",
description: "Event description",
endTimeUnspecified: null,
etag: ""3235420151680000"",
eventType: "default",
guestsCanInviteOthers: null,
guestsCanModify: null,
guestsCanSeeOtherGuests: null,
hangoutLink: null,
htmlLink: "https://www.google.com/calendar/event?eid=dXZyNHByamc0ZXNqbDkxajI5c3I0cWI3c28gZGxvcW45M2VoOWlsZm5lOWRjb2xodDY5aWtAZw",
iCalUID: "uvr4prjg4esjl91j29sr4qb7so@google.com",
id: "uvr4prjg4esjl91j29sr4qb7so",
kind: "calendar#event",
location: null,
locked: null,
privateCopy: null,
recurrence: null,
recurringEventId: null,
sequence: 0,
status: "confirmed",
summary: "A new event",
transparency: null,
updated: "2021-04-06T11:54:35.840Z",
visibility: null,
creator: {
displayName: null,
email: "mohamed-service-account@mohamed-project.iam.gserviceaccount.com",
id: null,
self: null
},
organizer: {
displayName: "Mohamed calendar",
email: "dloqn93eh9ilfne9dcolht69ik@group.calendar.google.com",
id: null,
self: true
},
start: {
date: null,
dateTime: "2021-04-06T13:54:35+02:00",
timeZone: null
},
end: {
date: null,
dateTime: "2021-04-06T14:54:35+02:00",
timeZone: null
},
reminders: {
useDefault: true
}
}
我通过将 service account
身份验证替换为 oauth
解决了这个问题。