認証が必要です
所定のタイムライン アイテムを更新します。 例を見る。
このメソッドは、/upload URI に対応し、次の特徴のメディアを受け入れます。
- 最大ファイルサイズ: 10MB
- 使用可能なメディア MIME タイプ:
audio/*,image/*,video/*
リクエスト
HTTP リクエスト
このメソッドは、2 つの URI を使用してメディアのアップロード機能を実行します。詳細については、メディアのアップロードのドキュメントをご覧ください。
- アップロード URI(メディア アップロード リクエスト用):
PUT https://www.googleapis.com/upload/mirror/v1/timeline/id
- メタデータ URI(メタデータのみのリクエストの場合):
PUT https://www.googleapis.com/mirror/v1/timeline/id
パラメータ
| パラメータ名 | 値 | 説明 |
|---|---|---|
| パスパラメータ | ||
id |
string |
タイムライン アイテムの ID。 |
| 必須のクエリ パラメータ | ||
uploadType |
string |
/upload URI へのアップロード リクエストのタイプ。
指定できる値は次のとおりです。
<ph type="x-smartling-placeholder">
|
承認
このリクエストは、少なくとも次のうち 1 つのスコープでの承認が必要です(認証と承認の詳細をご確認ください)。
| スコープ |
|---|
https://www.googleapis.com/auth/glass.timeline |
https://www.googleapis.com/auth/glass.location |
リクエスト本文
リクエストの本文で、次のプロパティをメタデータとして持つタイムライン リソースを指定します。詳しくは、メディアのアップロードに関するドキュメントをご覧ください。
| プロパティ名 | 値 | 説明 | メモ |
|---|---|---|---|
| 省略可能なプロパティ | |||
bundleId |
string |
このアイテムの一括販売 ID。サービスでは、bundleId を指定して多数のアイテムをグループ化できます。デバイスの 1 つの最上位アイテムの下に表示されます。 | 書き込み可能 |
canonicalUrl |
string |
タイムライン アイテムによって表されるデータの正規バージョンまたは高品質なバージョンを指す正規 URL。 | 書き込み可能 |
creator |
nested object |
このアイテムを作成したユーザーまたはグループ。 | 書き込み可能 |
displayTime |
datetime |
このアイテムがタイムラインに表示されるときに表示される時刻(RFC 3339 の形式)。このユーザーのタイムラインは表示時間順に並べられるため、タイムライン内の位置によってアイテムの表示位置も決まります。サービスで設定されていない場合、表示時間はデフォルトで updated 時間になります。 |
書き込み可能 |
html |
string |
このアイテムの HTML コンテンツ。アイテムに text と html の両方を指定すると、html がタイムラインにレンダリングされます。使用できる HTML 要素 - これらの要素はタイムライン カードで使用できます。
ブロックされる HTML 要素: これらの要素とそのコンテンツは、HTML ペイロードから削除されます。
その他の要素: リストにない要素は削除されますが、その内容は保持されます。 |
書き込み可能 |
isBundleCover |
boolean |
この商品がセット商品カバーかどうか。 アイテムが一括販売カバーとしてマークされている場合は、そのアイテムと同じ bundleId を持つアイテムの一括販売へのエントリ ポイントになります。メインのタイムラインにのみ表示され、開いたバンドルの中には表示されません。メインのタイムラインには次のアイテムが表示されます。
|
書き込み可能 |
location |
nested object |
このアイテムに関連付けられている地理的な位置です。 | 書き込み可能 |
menuItems[] |
list |
タイムラインでこのアイテムが選択されたときにユーザーに表示されるメニュー項目のリスト。 | 書き込み可能 |
menuItems[].action |
string |
ユーザーがメニュー オプションを選択したときの動作を制御します。使用できる値:
|
書き込み可能 |
menuItems[].id |
string |
このメニュー項目の ID。これはアプリケーションによって生成され、不透明トークンとして扱われます。 | 書き込み可能 |
menuItems[].payload |
string |
この MenuItem のアクションに応じて意味が変わる汎用ペイロード。
|
書き込み可能 |
menuItems[].removeWhenSelected |
boolean |
CUSTOM のメニュー項目で true に設定すると、その項目は選択後にメニューから削除されます。 |
書き込み可能 |
menuItems[].values[] |
list |
CUSTOM アイテムの場合、各状態におけるメニュー アイテムの外観を制御する値のリスト。DEFAULT 状態の値を指定する必要があります。PENDING または CONFIRMED の状態がない場合、それらは表示されません。 |
書き込み可能 |
menuItems[].values[].displayName |
string |
メニュー項目に表示する名前。組み込みメニュー項目にこのプロパティを指定すると、そのメニュー項目のデフォルトのコンテキスト音声コマンドは表示されません。 | 書き込み可能 |
menuItems[].values[].iconUrl |
string |
メニュー項目とともに表示するアイコンの URL。 | 書き込み可能 |
menuItems[].values[].state |
string |
この値が適用される州。使用できる値:
|
書き込み可能 |
notification |
nested object |
デバイスでのこのアイテムの通知の表示方法を管理します。指定されていない場合、通知は生成されません。 | 書き込み可能 |
notification.deliveryTime |
datetime |
通知を配信する時刻。 | 書き込み可能 |
notification.level |
string |
通知の重要度を表します。使用できる値:
|
書き込み可能 |
recipients[] |
list |
このアイテムを共有しているユーザーまたはグループのリストです。 | 書き込み可能 |
sourceItemId |
string |
独自のサービスのデータにタイムライン アイテムをマッピングするために使用できる不透明な文字列。 | 書き込み可能 |
speakableText |
string |
このアイテムのコンテンツの読み上げバージョン。READ_ALOUD のメニュー項目と併せて、このフィールドを使用して、読み上げたテキストが明瞭なテキストを提供したり、Glass で視覚的に表示される情報に詳細な情報を提供したりできます。Glassware では、speechableType フィールドも指定する必要があります。これは、追加のコンテキストが有用な場合(ユーザーが通知の後にアイテムを読み上げるようにする場合など)に、このテキストの前に読み上げられます。 |
書き込み可能 |
speakableType |
string |
このアイテムのタイプに関する音声による説明。これは、追加のコンテキストが有用である場合(通知の後でアイテムの読み上げをユーザーがリクエストした場合など)、アイテムを読む前にユーザーに読み上げられます。 「メール」、「テキスト メッセージ」、「Daily Planet News Update」などの短いシンプルな名詞にする必要があります。 Glassware では、ユーザーが画面を見ずにアイテムのタイプを確認できるように、タイムライン アイテムごとに、アイテムに speechableText やテキストが含まれていない場合でも、このフィールドに値を入力することが推奨されます。 |
書き込み可能 |
text |
string |
このアイテムのテキスト コンテンツ。 | 書き込み可能 |
title |
string |
このアイテムのタイトル。 | 書き込み可能 |
レスポンス
成功すると、このメソッドはレスポンスの本文でタイムライン リソースを返します。
例
注: このメソッドで使用可能なコード例では、サポートされているプログラミング言語すべての例を示しているわけではありません(サポートされている言語の一覧については、クライアント ライブラリ ページをご覧ください)。
Java
Java クライアント ライブラリを使用します。
import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.NotificationConfig;
import com.google.api.services.mirror.model.TimelineItem;
import java.io.IOException;
public class MyClass {
// ...
/**
* Update a timeline item in the user's Glass with an optional notification and attachment.
*
* @param service Authorized Mirror service.
* @param itemId ID of the timeline item to update.
* @param newText timeline item's text.
* @param newNotificationLevel Optional notification level, supported values
* are {@code null} and "AUDIO_ONLY".
* @return Updated timeline item on success, {@code null} otherwise.
*/
public static TimelineItem updateTimelineItem(Mirror service, String itemId, String newText,
String newNotificationLevel) {
try {
// First retrieve the timeline item from the API.
TimelineItem timelineItem = service.timeline().get(itemId).execute();
// Update the timeline item's metadata.
timelineItem.setText(newText);
if (newNotificationLevel != null && newNotificationLevel.length() > 0) {
timelineItem.setNotification(new NotificationConfig().setLevel(newNotificationLevel));
} else {
timelineItem.setNotification(null);
}
return service.timeline().update(itemId, timelineItem).execute();
} catch (IOException e) {
System.err.println("An error occurred: " + e);
return null;
}
}
// ...
}
.NET
.NET クライアント ライブラリを使用します。
using System;
using System.IO;
using Google.Apis.Mirror.v1;
using Google.Apis.Mirror.v1.Data;
public class MyClass {
// ...
/// <summary>
/// Update a timeline item in the user's Glass with an optional
/// notification and attachment.
/// </summary>
/// <param name='service'>Authorized Mirror service.</param>
/// <param name='itemId'>ID of the timeline item to update.</param>
/// <param name='newText'>Timeline Item's text content.</param>
/// <param name='newNotificationLevel'>
/// Optional notification level, supported values are null and
/// "AUDIO_ONLY".
/// </param>
/// <returns>
/// Updated timeline item on success, null otherwise.
/// </returns>
public static TimelineItem UpdateTimelineItem(MirrorService service,
String itemId, String newText, String newNotificationLevel) {
try {
// First retrieve the timeline item from the API.
TimelineItem timelineItem = service.Timeline.Get(itemId).Fetch();
// Update the timeline item's metadata.
timelineItem.Text = newText;
if (!String.IsNullOrEmpty(newNotificationLevel)) {
timelineItem.Notification = new NotificationConfig() {
Level = newNotificationLevel
};
} else {
timelineItem.Notification = null;
}
return service.Timeline.Update(timelineItem, itemId).Fetch();
} catch (Exception e) {
Console.WriteLine("An error occurred: " + e.Message);
return null;
}
}
// ...
}
PHP
PHP クライアント ライブラリを使用します。
/**
* Update a timeline item in the user's Glass with an optional
* notification and attachment.
*
* @param Google_MirrorSservice $service Authorized Mirror service.
* @param string $itemId ID of the timeline item to update.
* @param string $newText timeline item's text (can be HTML content).
* @param string $newNotificationLevel Optional notification level,
* supported values are {@code null} and "AUDIO_ONLY".
* @return Google_TimelineItem Updated timeline item on success,
* null otherwise.
*/
function updateTimelineItem($service, $itemId, $newText, $newNotificationLevel) {
try {
$timelineItem = $service->timeline->get($itemId);
$timelineItem->setText($newText);
if ($notificationlevel != null) {
$notification = new Google_NotificationConfig();
$notification->setLevel($newNotificationLevel);
$timelineItem->setNotification($notification);
} else {
$timelineItem->setNotification(null);
}
return $service->timeline->update($itemId, $timelineItem);
} catch (Exception $e) {
print 'An error occurred: ' . $e->getMessage();
return null;
}
}
Python
Python クライアント ライブラリを使用します。
import io
from apiclient import errors
from apiclient.http import MediaIoBaseUpload
# ...
def update_timeline_item(service, item_id, new_text,
new_notification_level=None):
"""Update a timeline item in the user's Glass.
Args:
service: Authorized Mirror service.
item_id: ID of the timeline item to update.
new_text: Timeline item's text (can be HTML content).
new_content_type: Optional attachment's content type (supported content
types are 'image/*', 'video/*' and 'audio/*').
new_attachment: Optional attachment as data string.
new_notification_level: Optional notification level, supported values are
None and 'AUDIO_ONLY'.
Returns:
Updated timeline item on success, None otherwise.
"""
try:
# First retrieve the timeline item from the API.
timeline_item = service.timeline().get(id=item_id).execute()
# Update the timeline item's metadata.
timeline_item['text'] = new_text
if new_notification_level:
timeline_item['notification'] = {'level': new_notification_level}
elif 'notification' in timeline_item:
timeline_item.pop('notification')
return service.timeline().update(id=item_id, body=timeline_item).execute()
except errors.HttpError, error:
print 'An error occurred: %s' % error
return None
Ruby
Ruby クライアント ライブラリを使用します。
##
# Update a timeline item in the user's glass.
#
# @param [Google::APIClient] client
# Authorized client instance.
# @param [String] item_id
# ID of the timeline item to update.
# @param [String] new_text
# Timeline item's new text.
# @param [String] new_notification_level
# Optional new notification level, supported values are nil and 'AUDIO_ONLY'.
# @return [Google::APIClient::Schema::Mirror::V1::TimelineItem]
# Updated timeline item instance if successful, nil otherwise.
def update_timeline_item(client, item_id, new_text, new_notification_level)
mirror = client.discovered_api('mirror', 'v1')
result = client.execute(
:api_method => mirror.timeline.get,
:parameters => { 'id' => item_id })
if result.success?
timeline_item = result.data
timeline_item.text = new_text
if new_notification_level
timeline_item.notification = { 'level' => new_notification_level }
else
timeline_item.notification = nil
end
result = client.execute(
:api_method => mirror.timeline.update,
:body_object => timeline_item,
:parameters => { 'id' => item_id })
if result.success?
return result.data
end
end
puts "An error occurred: #{result.data['error']['message']}"
end
Go
Go クライアント ライブラリを使用します。
import (
"code.google.com/p/google-api-go-client/mirror/v1"
"fmt"
)
// UpdateTimelineItem updates a timeline item in the user's timeline with an
// optional notification and attachment.
func UpdateTimelineItem(g *mirror.Service, itemId string, newNotificationLevel string) (
*mirror.TimelineItem, error) {
t, err := g.Timeline.Get(itemId).Do()
if err != nil {
fmt.Printf("An error occurred: %v\n", err)
return nil, err
}
t.Text = newText
if newNotificationLevel != "" {
t.Notification = &mirror.NotificationConfig{Level: newNotificationLevel}
} else {
t.Notification = nil
}
r, err := g.Timeline.Update(itemId, t).Do()
if err != nil {
fmt.Printf("An error occurred: %v\n", err)
return nil, err
}
return r, nil
}
未加工の HTTP
クライアント ライブラリは使用しません。
PUT /mirror/v1/timeline/timeline item id HTTP/1.1 Host: www.googleapis.com Authorization: Bearer auth token Content-Type: application/json Content-Length: 26 { "text": "Hello world" }