我正在使用 Google 的官方 js 客户端来访问 Google API,在本例中是 Google Glass Mirror API。
我需要一些有关如何使用update
甚至更好的patch
方法的指导(请参阅https://developers.google.com/glass/v1/reference/timeline)来更新我之前插入到时间线中的时间线卡。
插入和列出相当容易并且可以成功运行。我已经使用本教程开始:https ://github.com/emil10001/glass-mirror-nodejs-auth-demo/blob/master/app.js
我试过以下:
card = {
"kind": "mirror#timelineItem",
"id": "74b88eb3-a6d7-4c13-8b0e-bfdecf71c913",
"created": "2014-05-22T20:26:56.253Z",
"updated": "2014-05-22T20:27:18.961Z",
"etag": "1400790438961",
"text": "This item3 auto-resizes according to the text length",
"notification": {
"level": "DEFAULT"
}
}
client
.mirror.timeline.update({"id": card.id, resource: card})
.withAuthClient(oauth2Client)
.execute(function (err, data) {
if (!!err)
errorCallback(err);
else
successCallback(data);
});
我得到以下有效负载的成功响应:
{
kind: 'mirror#timelineItem',
id: '74b88eb3-a6d7-4c13-8b0e-bfdecf71c913',
selfLink: 'https://www.googleapis.com/mirror/v1/timeline/74b88eb3-a6d7-4c13-8b0e-bfdecf71c913',
created: '2014-05-22T20:26:56.253Z',
updated: '2014-05-22T20:32:11.862Z',
etag: '1400790731862'
}
我最终得到的是内容为空的卡片。我怀疑我没有正确使用更新方法并且第二个参数resource
没有正确命名?