如何删除事件谷歌日历api与通知(PHP)

时间:2018-04-27 01:50:43

标签: php curl google-api

这是我的PHP代码。

我不知道如何设置sendNotifications参数。

谷歌搜索这并没有帮助我找到解决方案。

<?php
......

public function DeleteCalendarEvent($event_id, $calendar_id, $access_token) {
        $url_events = 'https://www.googleapis.com/calendar/v3/calendars/' . $calendar_id . '/events/' . $event_id;

        $ch = curl_init();      
        curl_setopt($ch, CURLOPT_URL, $url_events);     
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);        
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');      
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer '. $access_token, 'Content-Type: application/json'));
        $data = json_decode(curl_exec($ch), true);
        $http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
        if($http_code != 204) 
            throw new Exception('Error : Failed to delete event');
    }

......
?>

1 个答案:

答案 0 :(得分:0)

“sendNotifications”是一个查询参数。 https://developers.google.com/calendar/v3/reference/events/delete

所以你可以简单地将它添加到URL

  

$ url_events ='https://www.googleapis.com/calendar/v3/calendars/'。 $ calendar_id。 '/ events /'。 。$ EVENT_ID '?sendNotification时=真';