bitcko / yii2-bitcko-google-calendar-api

Yii2 Bitcko Google Calendar Api Extension use to create and delete events from google calendar
3 stars 5 forks source link

Function for update event is not working #5

Open supreetSekhon opened 2 years ago

supreetSekhon commented 2 years ago

I created a function to update the event but it is not working. Following is the code I added in GoogleCalendarApi.php. Please hlep me out and let me know what am I doing wrong. I would really appreciate some help

  public function updateGoogleCalendarEvent($event,$eventId){

        if ($this->checkIfCredentialFileExists() ) {
            if( $this->is_connected()){
                try{
                    $this->checkAccessToken();
                    $service = new Google_Service_Calendar($this->client);
                    $calendarId = $this->calendarId;
                    $event = new Google_Service_Calendar_Event(array(
                        'summary' => $event['summary'],
                        'location' => $event['location'],
                        'description' => $event['description'],
                        'start' =>$event['start'],
                        'end' => $event['end'],
                        'recurrence'=>$event['recurrence'],
                        'attendees' => $event['attendees'],
                        'reminders' => $event['reminders']
                    ));
                    $opt_params = array(
                      'sendUpdates' => 'all'
                    );
                    return  $service->events->update($calendarId,$eventId,$event,$opt_params);
                }catch (Google_Service_Exception $e){
                    echo $e->getMessage();
                }
            }else{
                return false;
            }
        }
        return false;

    }