Add a livestream to Google Calendar event conference through API

Viewed 171

I'm trying to register events on Google Calendar through its API. After the event is created I add a conference with Google Meet so I can get a link. BUT Google Meet has 100 users max per conference so I want to add a livestream to the event because livestream can be viewed up to 100K users:

https://support.google.com/meet/answer/9308630?co=GENIE.Platform%3DDesktop&hl=en

This is how I'm creating the event in PHP:

function getClient(){
    $client = new Google_Client();
    $client->setApplicationName('Sala de Conferencia - PEV');
    $client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS);
    $client->setAuthConfig('credentials/client_secret_xxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com.json');
    $client->setAccessType('offline');
    $client->setPrompt('select_account consent');

    $tokenPath = 'credentials/conference-room-token.json';
    if (file_exists($tokenPath)) {
        $accessToken = json_decode(file_get_contents($tokenPath), true);
        $client->setAccessToken($accessToken);
    }

    if ($client->isAccessTokenExpired()) {
        if ($client->getRefreshToken()) {
            $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken());
        } else {
            $authUrl = $client->createAuthUrl();
            echo $authUrl;
            $authCode = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

            $accessToken = $client->fetchAccessTokenWithAuthCode($authCode);
            $client->setAccessToken($accessToken);

            if (array_key_exists('error', $accessToken)) {
                throw new Exception(join(', ', $accessToken));
            }
        }
        if (!file_exists(dirname($tokenPath))) {
            mkdir(dirname($tokenPath), 0700, true);
        }
        file_put_contents($tokenPath, json_encode($client->getAccessToken()));
    }
    return $client;
}

$client = getClient();
$calendarService = new Google_Service_Calendar($client);

$calendarId = 'primary';

$event = new Google_Service_Calendar_Event(array(
    'summary' => "xxxxxxxxxxxxxxxxx",
    'description' => "xxxxxxxxxxxxxxxxxx",
    'location' => '',
    'start' => array(
        'dateTime' => $start_date,
        'timeZone' => 'America/La_Paz',
    ),
    'end' => array(
        'dateTime' => $end_date,
        'timeZone' => 'America/La_Paz',
    ),
    'attendees' => $attendees,
    'organizer' => array(
        'email' => $USER->email,
        'displayName' => $USER->firstname.' '.$USER->lastname
    )
));

$optParams = Array('sendNotifications' => true);

$event = $calendarService->events->insert($calendarId, $event, $optParams);

$eventPatch = new Google_Service_Calendar_Event(array(
    'conferenceData' => array(
        'createRequest' => array(
            'requestId' => $pagedata['token']
        ),
        'notes' =>  "xxxxxxxxxxxxxxxxxxxxxxxx"
    )
));

$calendarService->events->patch($calendarId, $event->getId(), $eventPatch, array('conferenceDataVersion' => 1));

sleep(10);

$event = $calendarService->events->get($calendarId, $event->getId());

So I want to know how to register a livestream to an already created conference in google meet using google calendar php api.

Example: this is a Google Meet conference https://meet.google.com/cmc-byey-dgo

And this is the same conference registered livestream https://stream.meet.google.com/stream/56ac889b-4ac2-4fc4-890a-fe3fc5195f69

1 Answers

This is currently not possible and there is an open issue on the public issue tracker of the Google Calendar API.

Related