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

标签 google-calendar-api

我正在使用谷歌 API,https://developers.google.com/calendar/v3/reference/events/insert在日历中插入事件。单个事件插入成功,但有没有办法在单个标注中插入多个事件?

最佳答案

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

为什么要使用批处理? 使用批处理 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!!!')
});
  }

关于google-calendar-api - 在谷歌日历(API)中插入多个 calendar.events,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50467303/

相关文章:

rest - 谷歌日历 API : TimeZone not taken into account by google server?

java - 在谷歌日历事件中设置日期

python - Google App Engine urlfetch DeadlineExceededError 推送任务处理程序运行 apiclient 批处理请求

javascript - 如何在没有 session 的情况下将事件添加到谷歌日历API

google-calendar-api - Google Calendar feed timeMin timeMax 不工作

PHP 谷歌日历 API : Adding Multiple Events at Once

函数中的 Javascript(Google 脚本)值未返回

html - 添加到 iCal 和 google-calendar 按钮到页面

java - 如何使用 Google Calendar API 获取特定时间范围内的所有日历条目

google-apps-script - 使用 Google Apps 脚本从基于 Google 表格的 Google 日历中删除事件