如何使用CURL删除谷歌议程中的事件


How to delete an event in Google agenda with CURL?

我正在使用一个脚本来创建类似于的事件

$data = "<entry xmlns='http://www.w3.org/2005/Atom' " . 
            "xmlns:gd='http://schemas.google.com/g/2005'>'n" . 
            "<category scheme='http://schemas.google.com/g/2005#kind' " . 
            "term='http://schemas.google.com/g/2005#event'></category>'n" . 
            "<title type='text'>event title</title>'n" . 
            "<content type='text'>event description</content>'n" . 
            "<gd:transparency value='http://schemas.google.com/g/2005#event.opaque'>" . 
            "</gd:transparency>'n" . 
            "<gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'>" . 
            "</gd:eventStatus>'n" . 
            "<gd:where valueString='event address'></gd:where>" . 
            "<gd:when startTime='$date"."T$timestart:00.000+01:00' endTime='$date"."T$timeend:00.000+01:00'></gd:when>'n" . 
            "</entry>'n";
curl_setopt($cs, CURLOPT_URL, "https://www.google.com/calendar/feeds/default/private/full");
curl_setopt($cs, CURLOPT_POST, 1);
curl_setopt($cs,CURLOPT_HTTPHEADER,array('Accept: text/html,application/xhtml+xml,application/xml'));
curl_setopt($cs, CURLOPT_HEADER, 1);
curl_setopt($cs, CURLOPT_HTTPHEADER, $httpheader);
curl_setopt($cs, CURLOPT_POSTFIELDS, $data);

我可以获得事件ID,但我不知道如何删除它。

感谢

我假设您使用的是V2 API,因此根据文档:

要删除事件,首先检索要删除的事件,然后向事件的编辑URL发送DELETE请求。

因此,首先执行GET请求来获取您想要的事件,从XML中获取编辑链接,例如

<link rel='edit' type='application/atom+xml' href='https://www.google.com/calendar/feeds/jo@gmail.com/private-magicCookie/full/entryID'></link>

然后使用CURL对该URL执行DELETE请求。要了解更多信息,请参阅本页,其中解释了如何使用CURLOPT_CUSTOMREQUEST选项。