Google calendar api 在google日历(API)中插入多个calendar.events

Google calendar api 在google日历(API)中插入多个calendar.events,google-calendar-api,Google Calendar Api,我正在使用谷歌API,在日历中插入事件。单个事件已成功插入,但是否有一种方法可以在单个调用中插入多个事件?如本文所述,如果要同时插入多个事件,应使用 您还可以检查此项以获取其他参考。您需要使用批处理来添加/删除/更新事件 为什么使用批处理? 使用批处理API的主要原因是减少网络开销,从而提高性能 下面是一个示例,显示如何使用批处理来使用javascript/typescript动态添加事件 createMultipleEvents() { const events = [ {

我正在使用谷歌API,在日历中插入事件。单个事件已成功插入,但是否有一种方法可以在单个调用中插入多个事件?

如本文所述,如果要同时插入多个事件,应使用


您还可以检查此项以获取其他参考。

您需要使用批处理来添加/删除/更新事件

为什么使用批处理? 使用批处理API的主要原因是减少网络开销,从而提高性能

下面是一个示例,显示如何使用批处理来使用javascript/typescript动态添加事件

createMultipleEvents() {
    const events = [ {
      'summary': 'sample test events1',
      'location': 'coimbatore',
      'start': {
          'date': '2018-08-29',
          'timeZone': 'America/Los_Angeles'
      },
      'end': {
          'date': '2018-08-29',
          'timeZone': 'America/Los_Angeles'
      }
  },
  {
    'summary': 'sample test events2',
    'location': 'coimbatore',
    'start': {
        'date': '2018-08-29',
        'timeZone': 'America/Los_Angeles'
    },
    'end': {
        'date': '2018-08-29',
        'timeZone': 'America/Los_Angeles'
    }
},
];
const batch = gapi.client.newBatch();
events.map((r, j) => {
  batch.add(gapi.client.calendar.events.insert({
    'calendarId': 'primary',
    'resource': events[j]
  }))
})
batch.then(function(){
  console.log('all jobs now dynamically done!!!')
});
  }

谷歌开发者博客上宣布,全球HTTP批处理端点(www.googleapis.com/Batch)将于2020年8月12日停止工作。有关将服务转换为使用特定于API的HTTP批处理端点(www.googleapis.com/Batch/API/version)的说明,请参阅博客文章。

如何动态添加多个事件的可能重复?
createMultipleEvents() {
    const events = [ {
      'summary': 'sample test events1',
      'location': 'coimbatore',
      'start': {
          'date': '2018-08-29',
          'timeZone': 'America/Los_Angeles'
      },
      'end': {
          'date': '2018-08-29',
          'timeZone': 'America/Los_Angeles'
      }
  },
  {
    'summary': 'sample test events2',
    'location': 'coimbatore',
    'start': {
        'date': '2018-08-29',
        'timeZone': 'America/Los_Angeles'
    },
    'end': {
        'date': '2018-08-29',
        'timeZone': 'America/Los_Angeles'
    }
},
];
const batch = gapi.client.newBatch();
events.map((r, j) => {
  batch.add(gapi.client.calendar.events.insert({
    'calendarId': 'primary',
    'resource': events[j]
  }))
})
batch.then(function(){
  console.log('all jobs now dynamically done!!!')
});
  }