Timeline: update

Yetkilendirme gerektiriyor

Mevcut bir zaman çizelgesi öğesini günceller. Örneğe göz atın.

Bu yöntem, bir /upload URI'sini destekler ve aşağıdaki özelliklere sahip yüklenen medyayı kabul eder:

  • Maksimum dosya boyutu: 10 MB
  • Kabul edilen Medya MIME türleri: audio/* , image/* , video/*

İstek

HTTP isteği

Bu yöntem, iki ayrı URI aracılığıyla medya yükleme işlevi sağlar. Daha fazla bilgi için medya yükleme ile ilgili belgeye bakın.

  • Medya yükleme istekleri için yükleme URI'si:
    PUT https://www.googleapis.com/upload/mirror/v1/timeline/id
    .
  • Yalnızca meta veri istekleri için meta veri URI'si:
    PUT https://www.googleapis.com/mirror/v1/timeline/id
    .

Parametreler

Parametre adı Değer Açıklama
Yol parametreleri
id string Zaman çizelgesi öğesinin kimliği.
Gerekli sorgu parametreleri
uploadType string /upload URI'sine yükleme isteğinin türü. Kabul edilebilir değerler şunlardır:
  • media - Basit yükleme. Meta veri olmadan yalnızca medyayı yükleyin.
  • multipart - Çok parçalı yükleme. Tek bir istekte hem medyayı hem de meta verilerini yükleyin.
  • resumable - Devam ettirilebilir yükleme. Dosyayı, ilk isteğin meta verileri içerdiği en az iki istekten oluşan bir seri kullanarak devam ettirilebilir bir şekilde yükleyin.

Yetkilendirme

Bu istek, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir (kimlik doğrulama ve yetkilendirme hakkında daha fazla bilgi edinin).

Kapsam
https://www.googleapis.com/auth/glass.timeline
https://www.googleapis.com/auth/glass.location

İstek içeriği

İstek gövdesinde, meta veri olarak aşağıdaki özelliklere sahip bir Zaman Çizelgesi kaynağı sağlayın. Daha fazla bilgi için medya yükleme ile ilgili belgeye bakın.

Mülk adı Değer Açıklama Notlar
İsteğe Bağlı Özellikler
bundleId string Bu öğenin paket kimliği. Hizmetler, birçok öğeyi birlikte gruplandırmak için bir BundleId belirtebilir. Cihazda tek bir üst düzey öğenin altında görünürler. yazılabilir
canonicalUrl string Zaman çizelgesi öğesi tarafından temsil edilen verilerin standart/yüksek kaliteli sürümüne işaret eden standart URL. yazılabilir
creator nested object Bu öğeyi oluşturan kullanıcı veya grup. yazılabilir
displayTime datetime Bu öğe, RFC 3339'a göre biçimlendirilmiş olarak zaman çizelgesinde görüntülenirken gösterilmesi gereken zaman. Bu kullanıcının zaman çizelgesi, görüntüleme zamanına göre kronolojik olarak sıralanır. Bu nedenle, öğenin zaman çizelgesinde nerede görüntüleneceğini de bu belirler. Hizmet tarafından ayarlanmazsa görüntüleme süresi varsayılan olarak updated saatine ayarlanır. yazılabilir
html string Bu öğenin HTML içeriği. Bir öğe için hem text hem de html sağlanırsa html zaman çizelgesinde oluşturulur.

İzin verilen HTML öğeleri: Bu öğeleri zaman çizelgesi kartlarınızda kullanabilirsiniz.

  • Başlıklar: h1, h2, h3, h4, h5, h6
  • Resim sayısı: img
  • Listeler: li, ol, ul
  • HTML5 anlamı: article, aside, details, figure, figcaption, footer, header, nav, section, summary, time
  • Yapısal: blockquote, br, div, hr, p, span
  • Stil: b, big, center, em, i, u, s, small, strike, strong, style, sub, sup
  • Tablolar: table, tbody, td, tfoot, th, thead, tr

Engellenen HTML öğeleri: Bu öğeler ve içerikleri HTML yüklerinden kaldırılır.

  • Doküman başlıkları: head, title
  • Yerleştirilmiş öğeler: audio, embed, object, source, video
  • Çerçeveler: frame, frameset
  • Komut dosyası çalıştırma: applet, script

Diğer öğeler: Listelenmeyen tüm öğeler kaldırılır ancak içerikleri korunur.

yazılabilir
isBundleCover boolean Bu öğenin paket kapağı olup olmadığı.

Bir öğe paket kapağı olarak işaretlenirse bu öğe ile aynı bundleId öğesine sahip öğe paketine giriş noktası olur. Yalnızca ana zaman çizelgesinde gösterilir; açık pakette gösterilmez.

Ana zaman çizelgesinde gösterilen öğeler:
  • isBundleCover bulunan öğeler true olarak ayarlandı
  • bundleId içermeyen öğeler
Paket alt zaman çizelgesinde gösterilen öğeler şunlardır:
  • Söz konusu bundleId VE isBundleCover öğesinin false olarak ayarlandığı öğeler
yazılabilir
location nested object Bu öğeyle ilişkilendirilen coğrafi konum. yazılabilir
notification nested object Bu öğeyle ilgili bildirimlerin cihazda nasıl sunulacağını kontrol eder. Bu değer eksikse herhangi bir bildirim oluşturulmaz. yazılabilir
notification.deliveryTime datetime Bildirimin teslim edileceği saat. yazılabilir
notification.level string Bildirimin ne kadar önemli olduğunu açıklar. İzin verilen değerler:
  • DEFAULT - Varsayılan önemdeki bildirimler. Kullanıcıları uyarmak için bir zil çalınır.
yazılabilir
recipients[] list Bu öğenin paylaşıldığı kullanıcıların veya grupların listesi. yazılabilir
sourceItemId string Bir zaman çizelgesi öğesini kendi hizmetinizdeki verilerle eşlemek için kullanabileceğiniz şeffaf dize. yazılabilir
speakableText string Bu öğe içeriğinin sesli okunabilir sürümü. READ_ALOUD menü öğesiyle birlikte, bu alanı, sesli okunurken daha net olacak metin sağlamak veya Glass'ta görsel olarak görüntülenen kısımla ilgili genişletilmiş bilgiler sağlamak için kullanın.

Glassware ayrıca, ek bağlamın faydalı olduğu durumlarda (örneğin, kullanıcı bir bildirimin ardından öğenin sesli okunmasını istediğinde) bu metinden önce sesli olarak söylenen söylenebilirType alanını da belirtmelidir.
yazılabilir
speakableType string Bu öğenin türünün okunabilir bir açıklaması. Bu bilgi, ek bağlamın faydalı olduğu durumlarda (ör. kullanıcı bir bildirimin ardından öğenin sesli okunmasını istediğinde) öğenin içeriğini okumadan önce kullanıcıya duyurulur.

Bu, "E-posta", "Kısa mesaj" veya "Günlük Gezegen Haberleri Güncellemesi" gibi kısa ve basit bir isim ifadesi olmalıdır.

Kullanıcı ekrana bakmadan öğenin türünü öğrenebilmesi için, öğede söylenebilir metin veya metin bulunmasa bile bu alanın her zaman çizelgesi öğesi için doldurulması önerilir.
yazılabilir
text string Bu öğenin metin içeriği. yazılabilir
title string Bu öğenin başlığı. yazılabilir

Yanıt

Başarılı olursa bu yöntem yanıt gövdesinde bir Zaman çizelgesi kaynağı döndürür.

Örnekler

Not: Bu yöntem için kullanıma sunulan kod örnekleri, desteklenen tüm programlama dillerini kapsamaz (Desteklenen dillerin listesi için istemci kitaplıkları sayfasını inceleyin).

Java

Java istemci kitaplığını kullanır.

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 istemci kitaplığını kullanır.

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 istemci kitaplığını kullanır.

/**
 * 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 istemci kitaplığını kullanır.

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 istemci kitaplığını kullanır.

##
# 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 istemci kitaplığını kullanır.

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
}

Ham HTTP

İstemci kitaplığı kullanmaz.

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" }