Google Calendar API-检查是否存在冲突 [英] Google calendar API - check for conflicts
问题描述
我正在制作一个用于管理约会的小应用程序-我需要知道是否存在当前支持的方法来检查事件是否在Google日历中重叠.
I'm making a little app which manages appointments - I need to know if there's a currently supported way to check if an event overlaps within a google calendar.
基本上,我从应用程序创建的日历中读取事件列表,然后使用该日历填充我的应用程序.
Basically I read a list of events from my app's created calendar, and then populate my application using that.
然后,我添加一个日历事件.我需要检查它是否与已经存在的冲突.有没有办法使用他们的API?
Then, I add a calendar event. I need to check if it conflicts with what already exists. Is there a way to do this with their api?
推荐答案
The Google calendar api has a method called freebusy it basicly returns a list of events between a two times if they exist within a calendar.
在主日历上请求5月20日至5月25日之间的事件.
Request events between may 20th and may 25th on my primary calendar.
{
"timeMax": "2017-05-25T13:44:16.549Z",
"timeMin": "2017-05-20T13:44:16.549Z",
"items": [
{
"id": "primary"
}
]
}
结果
{
"kind": "calendar#freeBusy",
"timeMin": "2017-05-20T13:44:16.000Z",
"timeMax": "2017-05-25T13:44:16.000Z",
"calendars": {
"primary": {
"busy": [
{
"start": "2017-05-23T15:35:00Z",
"end": "2017-05-23T16:35:00Z"
},
{
"start": "2017-05-24T13:00:00Z",
"end": "2017-05-24T13:30:00Z"
}
]
}
}
}
这篇关于Google Calendar API-检查是否存在冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!