【发布时间】:2023-03-24 13:05:02
【问题描述】:
我正在使用谷歌日历 api,我想知道是否可以修补/更新受邀者的响应状态。我能够访问用户的谷歌日历并插入、删除和更新他们的谷歌日历。但我不知道如何更改用户的响应状态。
这是我试图修补事件的 patchdate 函数。
function patchDate(calendarid, dateFormat) {
gapi.client.load('calendar', 'v3', function() { // load the calendar api (version 3)
var request = gapi.client.calendar.events.patch({
'calendarId': 'primary', // calendar ID
"eventId": calendarid, // pass event id
"sendNotifications": true,
"resource": dateFormat // pass event details with api call
});
// handle the response from our api call
request.execute(function(resp) {
if(resp.error || resp == false) {
console.log("failed to update")
} else {
console.log("successfully updated")
}
console.log(resp);
});
});
}
这就是我调用函数的方式。我正在传递要修补的用户电子邮件。谷歌日历活动中有多个电子邮件地址,但我只想更改其中一个。在这种情况下,这将是 example@.com
var dateFormat = {
"email": 'example@.com',
"responseStatus": 'accepted'
};
patchDate(tableData[6], dateFormat)
当我尝试修补事件但响应状态没有改变时,我得到了 200 ok 响应。
【问题讨论】:
-
您是否尝试过来自API documentation 的 Try This 部分。结果一样吗?
-
@Kessy 我认为它的结果相同,但实现方式不同。我使用的实现来自谷歌日历快速入门教程,所以它也应该可以工作。这是我正在使用的完整实现。 developers.google.com/calendar/quickstart/js
标签: javascript google-api google-calendar-api google-apps google-api-js-client