我通过 Hangouts API 创建了一个机器人,现在想通过 Google Scripts 控制台POST
向 Google Calendar API ( Freebusy: query ) 发送请求:
function testPOST() {
var url = "https://www.googleapis.com/calendar/v3/freeBusy";
var datetimeMin = "2018-02-22T18:00:00.000Z";
var datetimeMax = "2018-02-22T20:00:00.000Z";
var payload =
{
"timeMin": datetimeMin,
"timeMax": datetimeMax,
"timeZone": "Europe/Paris",
"groupExpansionMax": 2,
"calendarExpansionMax": 5,
"items": [
{
//I read, that Gmail address is your default calendar ID
"id": "%my_email@gmail.com%"
}
]
}
var options =
{
"method": "POST",
"payload": payload,
"followRedirects": true,
"muteHttpExceptions": true
};
var result = UrlFetchApp.fetch(url, options);
if (result.getResponseCode() == 200) {
var params = JSON.parse(result.getContentText());
Logger.log(params.name);
Logger.log(params.blog);
} else {
Logger.log(result);
}
}
在执行result
isnull
或期间undefined
,Google 控制台会显示此对象,但它是空的。我检查了,指定电子邮件的默认日历是公开的。
有人可以弄清楚如何POST
通过 Google Scripts 控制台从 Hangouts API 发送 -request 吗?