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 内容。如果为某个项同时提供了 texthtml,则会在时间轴中呈现 html

允许的 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 的商品
在套装子时间轴中,会显示的商品:
  • 将相关“bundleIdisBundleCover”设置为 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 还应指定 talkableType 字段,在提供额外上下文的情况下(例如,当用户请求在通知后大声读出内容时),系统会在此文本之前读出该字段。
可写入
speakableType string 此项目类型的可朗读说明。如果其他上下文有用,例如,当用户请求在收到通知后大声朗读项目时,系统就会在读取项目内容前向用户读出。

这应该是个简短的名词短语,例如“电子邮件”“短信”或“每日星球新闻动态”。

建议通过 Glassware 为每个时间轴项填充此字段,即使相应项不包含 talkableText 或文本,以便用户无需查看屏幕即可了解相应项的类型。
可写入
text string 此项的文字内容。 可写入
title string 此项的标题。 可写入
updated datetime 此项内容的上次修改时间,格式遵循 RFC 3339 标准。

方法

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