如何使用hangoutLink创建谷歌日历活动(谷歌会议)



我使用spatie/laravel-google-calendar包创建有会议的事件,但它只创建没有会议的事件。我合并了这个提交

但"仍然在不开会的情况下创建活动"不起作用
这是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 SpatieGoogleCalendarEvent;
$event->name = 'A new event';
$event->description = 'Event description';
$event->startDateTime = CarbonCarbon::now();
$event->endDateTime = CarbonCarbon::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
}
}

我通过用oauth替换service account身份验证来解决此问题。

  • https://developers.google.com/calendar/quickstart/php
  • https://github.com/spatie/laravel-google-calendar#authentication-不授权2
  • https://www.youtube.com/watch?v=pOdgE22D-1U&t=730秒

最新更新