我的目标:Google云端硬盘中的更改=>推送通知到https://script.google.com/a/macros/my-domain/ ... =>推送应用以采取措施.我不想设置一个中间Webhook代理来接收通知.相反,让Web App(通过Google Script)接收并直接推送.
由于相关功能完全没有记录(只在这里:https://developers.google.com/drive/web/push),下面是我尝试但失败的代码.1.上述想法是否可行?2.我的代码doPost(R)似乎无法正确接收通知(R参数).无论如何,我更改Google云端硬盘后没有回复.任何问题?(我已尝试记录输入参数R,以便查看其真实结构,并确定OAuth的参数Obj是否与普通Drive App相同,但在日志之前发生错误)
function SetWatchByOnce(){
var Channel = {
'address': 'https://script.google.com/a/macros/my-domain/.../exec',
'type': 'web_hook',
'id': 'my-UUID'
};
var Result = Drive.Changes.watch(Channel);
...
}
function doPost(R) {
var SysEmail = "My Email";
MailApp.sendEmail(SysEmail, 'Testing ', 'Successfully to received Push Notification');
var Response = JSON.parse(R.parameters);
if (Response.kind == "drive#add") {
var FileId = Response.fileId;
MyFile = DriveApp.getFolderById(FileId);
...
}
}
function doGet(e) {
var HTMLToOutput;
var SysEmail = "My Email";
if (e.parameters.kind) {
//I …Run Code Online (Sandbox Code Playgroud) webhooks push-notification google-apps-script google-drive-api