Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update attendees response status - Google Calendar API (PHP)

I've made a little application that uses Google Calendar API and Oauth2. Now I would like to allow user to answer at an event. This is my code:

PHP

if(isset($_POST['submit'])){

    $eventSubmit = $service->events->get('primary', $_POST['eventID']);
    $attendeesSubmit=$eventSubmit->getAttendees();

    foreach ($attendees as $attendee) {
        $mailSubmit = $attendee->getEmail();

        if ($mailSubmit==$emailUser){

            if ($_POST['status']=='accepte'){
               $attendee->setResponseStatus('accepted');
               $service->events->update('primary', $_POST['eventID'], $eventSubmit);

            }
            if ($_POST['status']=='decline'){
                $attendee->setResponseStatus('decline');
            }

        }

}

HTML

    <form method="post" action="index.php">
    <input type="radio" name="status" id="accepte" value="accepte">Confirmer</input>
    <input type="radio" name="status" id="decline" value="decline">Décliner</input>
    <input type="hidden" name="eventID" value="<?php echo htmlspecialchars($event['id']); ?>">
    <input type="submit" name="submit" value="OK"></br></br>

But It doesn't work, user's reponse status doesn't change when I'm submit the form. What's the problem?

like image 484
Kroll Avatar asked May 15 '26 19:05

Kroll


1 Answers

Event creators/owners can't modify the response of attendees. Only attendees can modify their status. Either attendees will need to respond from the Google Calendar UI themselves or you'll need to authenticate as the attendee user and change their response status.

like image 199
Jay Lee Avatar answered May 17 '26 07:05

Jay Lee