googleapis / google-api-php-client

A PHP client library for accessing Google APIs
Apache License 2.0
9.22k stars 3.52k forks source link

Organizer is set to "join now" immediately but i have to set other selected attendees also "join now" immediately without asking "ask to join" #2609

Open ArjunChaudhary01 opened 3 weeks ago

ArjunChaudhary01 commented 3 weeks ago
        // Prepare attendees array
        $attendees = [];
        // Add organizer with 'responseStatus' set to 'accepted'
        $attendees[] = new \Google_Service_Calendar_EventAttendee([
            'email' => $user->email,
            'responseStatus' => 'accepted', // Organizer should join immediately
        ]);

        // Add selected attendees with 'responseStatus' set to 'accepted'
        foreach ($this->staff as $userId) {
            $attendeeUser = User::find($userId);
            if ($attendeeUser) {
                $attendees[] = new \Google_Service_Calendar_EventAttendee([
                    'email' => $attendeeUser->email,
                    'responseStatus' => 'accepted', // Selected attendees should join immediately  (this responsestatus not working)
                ]);
            }
        }
        // Create Event
        $event = new Calendar\Event([
            'summary' => $this->title,
            'start' => new Calendar\EventDateTime([
                'dateTime' => $startDateTime,
                'timeZone' => 'Asia/Tokyo',
            ]),
            'end' => new Calendar\EventDateTime([
                'dateTime' => $endDateTime,
                'timeZone' => 'Asia/Tokyo',
            ]),
            'attendees' =>  $attendees, // Add attendees
            'conferenceData' => new Calendar\ConferenceData([
                'createRequest' => new Calendar\CreateConferenceRequest([
                    'requestId' => uniqid(),
                    'conferenceSolutionKey' => new Calendar\ConferenceSolutionKey([
                        'type' => 'hangoutsMeet',
                    ]),
                ]),
            ]),
            'visibility' => 'public', // Make the event public
        ]);

please comment on this