全部時間軸卡顯示你的用戶看到的內容是用戶體驗的核心。時間軸卡能夠是文字,豐富的HTML,圖像或視頻。您也能夠時間表卡捆綁在一塊兒,成一個的時間表卡,擴展到一個子時間表,便於組織。html
谷歌鏡API操做,如建立,更新,刪除,更提供端點。java
時間軸卡的更多信息,請參閱如下資源:python
一、開發人員指南android
下面是一個例子,一組佈置在用戶的時間軸的時間軸卡:json
1>插入一個時間表項目:api
http數組
POST /mirror/v1/timeline HTTP/1.1
Host: www.googleapis.com
Authorization:Bearer{auth token}
Content-Type: application/json
Content-Length:26
{"text":"Hello world"}
javaapp
TimelineItem timelineItem =newTimelineItem();
timelineItem.setText("Hello world");
service.timeline().insert(timelineItem).execute();
pythoneclipse
timeline_item ={'text':'Hello world'}
service.timeline().insert(body=timeline_item).execute()
成功時,您會收到201建立
響應代碼建立項目的完整副本。對於前面的例子,一個成功的響應可能看起來像這樣:ide
HTTP/1.1201Created
Date:Tue,25Sep201223:30:11 GMT
Content-Type: application/json
Content-Length:303
{
"kind":"glass#timelineItem",
"id":"1234567890",
"selfLink":"https://www.googleapis.com/mirror/v1/timeline/1234567890",
"created":"2012-09-25T23:28:43.192Z",
"updated":"2012-09-25T23:28:43.192Z",
"etag":"\"G5BI0RWvj-0jWdBrdWrPZV7xPKw/t25selcGS3uDEVT6FB09hAG-QQ\"",
"text":"Hello world"
}
插入項目,將出如今用戶的時間軸看起來像這樣:
2>插入帶有附件的項目時間表:
一張圖片賽過千言萬語,這是不少比你更能夠融入一個時間表的項目。爲此,你也能夠附加圖片和視頻的時間表項目。如何插入一個時間表的項目照片附件下面是一個例子:
http
POST /upload/mirror/v1/timeline HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer {auth token}
Content-Type: multipart/related; boundary="mymultipartboundary"
Content-Length: {length}
--mymultipartboundary
Content-Type: application/json; charset=UTF-8
{ "text": "A solar eclipse of Saturn. Earth is also in this photo. Can you find it?" }
--mymultipartboundary
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
[binary image data]
--mymultipartboundary--
java
TimelineItem timelineItem = new TimelineItem(); timelineItem.setText("Hello world"); InputStreamContent mediaContent = new InputStreamContent(contentType, attachment); service.timeline().insert(timelineItem, mediaContent).execute();
python
timeline_item = {'text': 'Hello world'} media_body = MediaIoBaseUpload( io.BytesIO(attachment), mimetype=content_type, resumable=True) service.timeline().insert(body=timeline_item, media_body=media_body).execute()
時間軸項目附加圖像看起來像這樣在玻璃上:
Note: At a low level, attachments are uploaded using HTTP Multipart. Google APIs client libraries make this easy using media upload.
最大的可能性冰法上傳圖片,使用谷歌api客戶端更加方便實用
3>增長視頻
POST /upload/mirror/v1/timeline HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer {auth token}
Content-Type: multipart/related; boundary="mymultipartboundary"
Content-Length: {length}
--mymultipartboundary
Content-Type: application/json; charset=UTF-8
{ "text": "Skateboarding kittens" }
--mymultipartboundary
Content-Type: video/vnd.google-glass.stream-url
http://example.com/path/to/kittens.mp4
--mymultipartboundary--
See supported media formats for a list of supported media types.
查看支持的視頻格式列表
3>閱讀時間表項目
你的服務能夠訪問全部的時間表,它建立項目,以及全部共享項目時間表。如下是如何 爲您服務是可見的項目列出時間表。
http
GET /mirror/v1/timeline HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer {auth token}
java
TimelineItem timelineItem = new TimelineItem(); service.timeline().list().execute();
pyton
service.timeline().list().execute()
4>訪問附件
您能夠訪問附件的時間表項目名爲「 附件「
經過一個數組屬性。而後,您能夠經過contentUrl
物業附件或 附件端點的附件的二進制數據 。
注:附件內容是受保護的OAuth 2.0,就像其餘調用的API端點。谷歌API客戶端庫提供訪問附件使用媒體下載功能的二進制內容。
http
GET /mirror/v1/timeline/{itemId}/attachments/{attachmentId} HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer {auth token}
java
TimelineItem item = service.timeline().get(itemId).execute(); String attachmentId = item.getAttachments().get(0).getId(); service.attachments().get(itemId, attachmentId).executeAsInputStream();
5>捆綁卡
捆綁可讓你結合許多有關卡可擴展,可摺疊成捆蓋卡。束區別於正常時間軸卡的一個頁面捲曲束的蓋卡右上角。
用戶水龍頭捆綁蓋卡擴展卡捆綁到一個子時間表是獨立在主時間軸上。用戶能夠刷卡子時間軸來查看卡,並經過刷卡,能夠返回到主時間軸上來回。如下圖片展現捆蓋卡在右上角卷頁和它下面的兩個捆綁卡。
有兩種方式捆綁內容:尋呼和線程。
使用分頁的內容,不適合在單一時間軸卡。分頁卡包中的全部共享相同的timelineId
,所以有相同的一組菜單項。分頁卡中,指定值 []
屬性timelineItem.htmlPages
。
使用線程捆綁相關的項目,如電子郵件線程。主題時間表卡,建立他們bundleId
相同的值 。最近添 加的項目是捆綁的封面卡。