返回 登录
0

谷歌开放Calendar API,允许你添加Google Drive文件至Calendar事件

Google Calendar API允许你创建和修改Google Calendar上的事件。从今天开始,你可以使用API来添加Google Drive文件至Calendar事件,在你的App上实现,从而提高可用性和集成性。有了这个API你可以轻松地连接会议记录、添加预定好的PDFs至事件。

这里是设置方法:

  1. 从Google Drive获得文件信息(例子,通过Google Drive API):
GET https://www.googleapis.com/drive/v2/files

{
 ...
 "items": [
  {
   "kind": "drive#file",
   "id": "9oNKwQI7dkW-xHJ3eRvTO6Cp92obxs1kJsZLFRGFMz9Q,
   ...
   "alternateLink": "https://docs.google.com/presentation/d/9oNKwQI7dkW-xHJ3eRvTO6Cp92obxs1kJsZLFRGFMz9Q/edit?usp=drivesdk",
   "title": "Workout plan",
   "mimeType": "application/vnd.google-apps.presentation",
   ...
  },
  ...
 ]
}
  1. 使用Calendar API进行操作,实现此信息传送至事件:
POST https://www.googleapis.com/calendar/v3/calendars/primary/events?supportsAttachments=true

{
  "summary": "Workout",
  "start": { ... },
  "end": { ... },
  ...
  "attachments": [
   {
      "fileUrl": "https://docs.google.com/presentation/d/9oNKwQI7dkW-xHJ3eRvTO6Cp92obxs1kJsZLFRGFMz9Q/edit?usp=drivesdk",
      "title": "Workout plan",
      "mimeType": "application/vnd.google-apps.presentation"
   },
   ...
  ]
}

图片描述

看!你不需要做什么特别的操作就可实现啦,下一步:

GET https://www.googleapis.com/calendar/v3/calendars/primary/events/ja58khmqndmulcongdge9uekm7

{
 "kind": "calendar#event",
 "id": "ja58khmqndmulcongdge9uekm7",
 "summary": "Workout",
 ...
 "attachments": [
  {
   "fileUrl": "https://docs.google.com/presentation/d/9oNKwQI7dkW-xHJ3eRvTO6Cp92obxs1kJsZLFRGFMz9Q/edit?usp=drivesdk",
   "title": "Workout plan",
   "mimeType": "application/vnd.google-apps.presentation",
   "iconLink": "https://ssl.gstatic.com/docs/doclist/images/icon_11_presentation_list.png"
  },
  ...
 ]
}

看 Google Calendar API 文件上的指南和参考以获得更多的细节。

反馈途径:在StackOverflow.com上使用
tag #google-calendar即可。


英文原文:Attach Google Drive files to Calendar events with the Calendar API

评论