Timeline

如需了解此资源的方法列表,请参阅本页结尾部分。

资源表示形式

用户时间轴中的每一项都以 TimelineItem JSON 结构表示,如下所述。

{
  "kind": "mirror#timelineItem",
  "id": string,
  "sourceItemId": string,
  "canonicalUrl": string,
  "bundleId": string,
  "isBundleCover": boolean,
  "selfLink": string,
  "created": datetime,
  "updated": datetime,
  "displayTime": datetime,
  "isPinned": boolean,
  "pinScore": integer,
  "isDeleted": boolean,
  "etag": etag,
  "creator": contacts Resource,
  "recipients": [
    contacts Resource
  ],
  "inReplyTo": string,
  "title": string,
  "text": string,
  "html": string,
  "speakableType": string,
  "speakableText": string,
  "attachments": [
    timeline.attachments Resource
  ],
  "location": locations Resource,
  "menuItems": [
    {
      "id": string,
      "action": string,
      "values": [
        {
          "state": string,
          "displayName": string,
          "iconUrl": string
        }
      ],
      "removeWhenSelected": boolean,
      "payload": string
    }
  ],
  "notification": {
    "level": string,
    "deliveryTime": datetime
  }
}
属性名称 说明 备注
attachments[] list 与此内容相关的媒体附件列表。为方便起见,您可以使用附件或 CID 方案来引用 HTML 载荷中的附件。例如:
  • attachments:<img src="attachment:attachment_index">,其中 attachments_index 是此数组中从 0 开始的索引。
  • cid: <img src="cid:attachment_id">,其中 attachments_id 为附件的 ID
bundleId string 此内容的软件包 ID。服务可以指定 bundleId 以将许多项组合在一起。它们显示在设备上的单个顶级项下。 可写入
canonicalUrl string 指向由时间轴项表示的规范/高质量版本的规范网址。 可写入
created datetime 此商品的创建时间,采用 RFC 3339 格式。
creator nested object 创建此内容的用户或群组。 可写入
displayTime datetime 当在时间轴中查看此商品时显示的时间,采用 RFC 3339 格式。该用户的时间轴按展示时间排序,这也决定了该内容在时间轴中的显示位置。如果未通过服务设置,则显示时间默认为 updated 时间。 可写入
etag etag 此商品的 ETag。
html string 此内容的 HTML 内容。如果同时为内容提供了 texthtmlhtml 将在时间轴中呈现。

允许使用的 HTML 元素 - 您可以在时间轴卡片中使用这些元素。

  • 标题:h1, h2, h3, h4, h5, h6
  • 图片:img
  • 列表:li, ol, ul
  • HTML5 语义:article, aside, details, figure, figcaption, footer, header, nav, section, summary, time
  • 结构体:blockquote, br, div, hr, p, span
  • 样式:b, big, center, em, i, u, s, small, strike, strong, style, sub, sup
  • 表:table, tbody, td, tfoot, th, thead, tr

屏蔽的 HTML 元素:这些元素及其内容会从 HTML 载荷中移除。

  • 文档标头:head, title
  • 嵌入:audio, embed, object, source, video
  • 帧数:frame, frameset
  • 脚本:applet, script

其他元素:系统会移除未列出的所有元素,但会保留其中的内容。

可写入
id string 时间轴项的 ID。这在用户时间轴中是唯一的。
inReplyTo string 如果此商品是作为对另一商品的回复生成的,则此字段将设为所回复商品的 ID。此功能可用于将回复附加到相应对话或帖子中。
isBundleCover boolean 这项内容是否为套装封面。

如果将某项内容标记为内容集封面,则该项将成为与该内容具有相同 bundleId 的内容集的入口点。它只会显示在主时间轴上,不会显示在打开的集合中

主时间轴上会显示以下内容:
  • isBundleCover 设为 true 的商品
  • 没有 bundleId 的项
在套装子时间轴中,显示的内容为:
  • 相关 bundleId isBundleCover 设为 false 的商品
可写入
isDeleted boolean 如果为 true,则表示此商品已删除,仅设置了 ID 属性。
isPinned boolean 如果为 true,则表示此内容与主屏幕中的另一侧(例如未固定的时间轴项)已固定在主屏幕上的“活跃”项(如导航和环聊)中。您可以允许用户通过 TOGGLE_PINNED 内置菜单项切换此属性的值。
kind string 资源的类型。始终为 mirror#timelineItem
location nested object 与此商品相关联的地理位置。 可写入
notification nested object 控制此设备上的通知在设备上的呈现方式。如果缺失,则不会生成通知。 可写入
notification.deliveryTime datetime 通知的发送时间。 可写入
notification.level string 描述通知的重要程度。允许的值包括:
  • DEFAULT - 默认重要性通知。系统会播放提示音来提醒用户。
可写入
pinScore integer 对于已固定的项,此属性可确定项在时间轴中的显示顺序,得分越接近时钟显示。注意:目前不支持设置此字段。
recipients[] list 共享此内容的用户或群组列表。 可写入
sourceItemId string 不透明字符串,可用于将时间轴项映射到您自己服务中的数据。 可写入
speakableText string 此内容的可朗读版本。与 READ_ALOUD 菜单项一起使用时,此字段可用于提供大声朗读时更清晰的文本,或者为 Glass 上所显示内容提供扩展信息。

Glassware 还应该指定 SpeakableType 字段,该字段在其他上下文有用时(例如,用户请求在通知后朗读项目)将在此文本之前读出。
可写入
speakableType string 此项目类型的可朗读说明。如果附加上下文有用(例如,用户要求在通知后朗读某个项),系统会在读取内容之前通知用户。

这应为简短名词短语,例如“Email”、“Text message”或“Daily Planet News Update”。

建议为每项时间轴项(即使项不包含 SpeakableText 或文本)填写 Glassware 这个字段,这样用户不必查看屏幕也能了解项的类型。
可写入
text string 此内容的文本内容。 可写入
title string 此项目的标题。 可写入
updated datetime 上次修改此商品的时间,其格式遵循 RFC 3339。

方法

delete
删除时间轴项。
get
根据 ID 获取单个时间轴项。
插入
在时间轴中插入新项。
list
检索经过身份验证的用户的时间轴项目列表。
补丁程序
更新已到的时间轴项。此方法支持补丁语义
update
更新已到的时间轴项。