我在我的网站上整合了谷歌驱动器API推送通知。 工作电流:开发者控制台,域等上如何获取Google Drive上已更改文件的ID
- 注册的Web应用程序...
- OAuth授权
- 如果不存在
- 设置的servlet创建信道等待谷歌驱动POST请求,如果发生变化
- 更改发生在谷歌驱动器(上传或删除)
- Servlet捕捉来自谷歌驱动器的POST请求发生变化时
- 缓存的消息:
{ "kind": "drive#change", "id": "8664", "selfLink": "https://www.googleapis.com/drive/v2/changes/8664"}
谷歌更改文件的驱动器API表示:
{
"kind": "drive#change",
"id": long,
"fileId": string,
"selfLink": string,
"deleted": boolean,
"modificationDate": datetime,
"file": files Resource
}
如何获得FILEID?为什么Google云端硬盘不会向我发送缺少的字段?我究竟做错了什么?
关注变化代码:
service -> created ok
channelId -> UUID
channelType -> web_hook
channelAddress -> https://example.com/GoogleDriveWebhook (GoogleDriveWebhook is servlet)
public static Channel watchChange(Drive service, String channelId, String channelType, String channelAddress) {
Channel channel = new Channel();
channel.setId(channelId);
channel.setType(channelType);
channel.setAddress(channelAddress);
channel.setExpiration(new Date().getTime() + (600000 * 2));//20 min session for channel (test environment)
try {
return service.changes().watch(channel).execute();
} catch (IOException e) {
System.out.println("Something is wrong with instancing new channel");
e.printStackTrace();
}
return null;
}
...所以很明显的应用程序捕获的变化,谷歌驱动器发送,我坚持plz帮助!
你在寻找什么样的缺失参数?请检查此页面的响应资源:https://developers.google.com/drive/web/push – KRR 2015-02-24 23:22:14
Thx我读它,所以这推送通知并没有真正告诉我什么文件被改变,只是通知我,已经改变了谷歌驱动器或? 然后,我尝试使用“Changes:get”API,使用参数:(Drive service,String changeId),其中我通过{“kind”:“drive#change”,**“id”:“8664”**,“selfLink “:”https://www.googleapis.com/drive/v2/changes/8664“} id像字符串changedId,但我总是得到”更改未找到:8754“上传或删除 – 2015-02-25 08:38:39