如何确定在Google Mirror API中触发了哪个自定义菜单项?

时间:2013-12-30 18:32:57

标签: google-glass google-mirror-api

确定在Python中选择了哪个自定义菜单项时遇到一些麻烦。

如果我有下面的菜单,并且在通知处理代码中检索到了卡片(html = item [“html”]),我该如何实际访问id值(“verify”)?

  "menuItems": [      
      { "action": "CUSTOM",
        "id":"verify",
        "values":
        [
          {
            "displayName": "Verify Incident",
            "iconUrl": "https"
          }
        ]
      }
  ]

1 个答案:

答案 0 :(得分:2)

您为自定义menuItem获得的通知应如下所示:

{
  "collection": "timeline",
  "itemId": "{long_id}",
  "operation": "UPDATE",
  "userToken": "{userToken}",
  "userActions": [
    {
      "type": "CUSTOM",
      "payload": "verify"
    }
  ]
}

payload返回您为menuItem指定的ID。

另见这些链接: https://developers.google.com/glass/develop/mirror/subscriptions#custom_menu_item_selected https://developers.google.com/glass/develop/mirror/menu-items#defining_custom_menu_items