Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Google Calander API中删除事件_Javascript_Node.js_Google Api_Google Calendar Api - Fatal编程技术网

Javascript 在Google Calander API中删除事件

Javascript 在Google Calander API中删除事件,javascript,node.js,google-api,google-calendar-api,Javascript,Node.js,Google Api,Google Calendar Api,Google没有关于如何删除node.JS中事件的文档 我可以使用以下代码将新事件添加到日历中: calendar.events.insert({ auth: auth, calendarId: 'primary', resource: event, }, function(err, event) { if (err) { console.log('There was an error contacting the Calendar ser

Google没有关于如何删除node.JS中事件的文档

我可以使用以下代码将新事件添加到日历中:

    calendar.events.insert({
    auth: auth,
    calendarId: 'primary',
    resource: event,
    }, function(err, event) {
    if (err) {
    console.log('There was an error contacting the Calendar service: ' +      err);
    return;
  }
  console.log('Event created: %s', event.htmlLink);
});

我已经花了4个小时来处理这个问题,正在寻找解决方案。

要删除事件,只需调用delete方法。以下代码可以在Node.js GitHub repo上找到,用于Google API

  delete: function (params, callback) {
  var parameters = {
    options: {
      url: 'https://www.googleapis.com/calendar/v3/users/me/calendarList/{calendarId}',
      method: 'DELETE'
    },
    params: params,
    requiredParams: ['calendarId'],
    pathParams: ['calendarId'],
    context: self
  };

  return createAPIRequest(parameters, callback);
}
发件人:

如果您希望将其作为功能:

首先获取要删除的事件的eventId,然后使用该eventId调用下面的方法

function deleteEvent(eventId) {

      var params = {
        calendarId: 'primary',
        eventId: eventId,
      };

      calendar.events.delete(params, function(err) {
        if (err) {
          console.log('The API returned an error: ' + err);
          return;
        }
        console.log('Event deleted.');
      });
    }

我希望它能帮助有同样问题的人

function deleteEvent(event_id) {
    gapi.client.load('calendar', 'v3', function() {
        var request = gapi.client.calendar.events.delete({
            'calendarId': 'xxxxxxxxxxxxxxx',
            'eventId': event_id
        });
        request.execute(function(response) {
            if(response.error || response == false){
                alert('Error');
            }
            else{
                alert('Success');               
            }
        });
    });
}

我得到一个关于“calendar.events.delete”行的错误,该行显示“后面缺少名称”。接线员。“。有什么建议吗?我可以发送注释或原因来删除事件吗?在上面的示例中,我们正在发送带有Calenariad和EventId的参数。我们可以发送注释或原因来取消事件吗?是否有删除多个事件的功能?