Timeline: update

অনুমোদন প্রয়োজন

টাইমলাইন আইটেম আপডেট করে। একটি উদাহরণ দেখুন।

এই পদ্ধতিতে /upload URI কাজ করে এবং নিম্নলিখিত বৈশিষ্ট্য সহ আপলোড করা মিডিয়া গ্রহণ করে:

  • ফাইলের সর্বাধিক সাইজ: ১০ এমবি
  • গ্রহণযোগ্য মিডিয়া MIME-এর ধরন: audio/* , image/* , video/*

অনুরোধ করুন

HTTP অনুরোধ

এই পদ্ধতি দুটি আলাদা URI-এর মাধ্যমে মিডিয়া আপলোড করার কার্যকারিতা প্রদান করে। আরও তথ্যের জন্য, মিডিয়া আপলোড সংক্রান্ত ডকুমেন্ট দেখুন।

  • মিডিয়া আপলোড করার অনুরোধের জন্য URI আপলোড করুন:
    PUT https://www.googleapis.com/upload/mirror/v1/timeline/id
  • মেটাডেটা URI, শুধুমাত্র মেটাডেটা সংক্রান্ত অনুরোধের জন্য:
    PUT https://www.googleapis.com/mirror/v1/timeline/id

প্যারামিটারগুলি

প্যারামিটারের নাম ভ্যালু বিবরণ
পাথ প্যারামিটার
id string টাইমলাইন আইটেমের আইডি।
প্রয়োজনীয় কোয়েরি প্যারামিটার
uploadType string /upload URI-তে আপলোড সংক্রান্ত অনুরোধের ধরন। গ্রহণযোগ্য মান হল:
  • media - সহজ আপলোড। কোনও মেটাডেটা ছাড়াই শুধু মিডিয়া আপলোড করুন।
  • multipart - মাল্টিপার্ট আপলোড। একটি অনুরোধেই মিডিয়া ও তার মেটাডেটা আপলোড করুন।
  • resumable - আপলোড আবার শুরু করা যাবে। অন্তত দুটি অনুরোধের একটি সিরিজ ব্যবহার করে, রেজুমে করা যায় এমনভাবে ফাইল আপলোড করুন, যেখানে প্রথম অনুরোধে মেটাডেটা অন্তর্ভুক্ত থাকে।

অনুমোদন

এই অনুরোধের জন্য নিম্নলিখিত এক বা একাধিক স্কোপের সাথে অনুমোদন প্রয়োজন (যাচাইকরণ ও অনুমোদন সম্পর্কে আরও জানুন)।

সুযোগ
https://www.googleapis.com/auth/glass.timeline
https://www.googleapis.com/auth/glass.location

অনুরোধের বডি

অনুরোধের প্রধান অংশে, মেটাডেটা হিসেবে নিম্নলিখিত প্রপার্টি সহ একটি টাইমলাইন রিসোর্স প্রদান করুন। আরও তথ্যের জন্য, মিডিয়া আপলোড সংক্রান্ত ডকুমেন্ট দেখুন।

প্রপার্টির নাম ভ্যালু বিবরণ নোট
ঐচ্ছিক প্রপার্টি
bundleId string এই আইটেমের বান্ডেল আইডি। পরিষেবাগুলি অনেক আইটেম একসাথে গ্রুপ করার জন্য একটি bundleId নির্দিষ্ট করতে পারে। ডিভাইসে একটি টপ-লেভেল আইটেমের অধীনে এগুলি দেখা যায়। রাইট করা যাবে
canonicalUrl string টাইমলাইন আইটেম দ্বারা দেখানো ডেটার সেরা/খুব ভাল কোয়ালিটির ভার্সন নির্দেশ করে এমন একটি সেরা URL। রাইট করা যাবে
creator nested object যে ব্যবহারকারী বা গ্রুপ এই আইটেম তৈরি করেছে। রাইট করা যাবে
displayTime datetime টাইমলাইনে এই আইটেমটি দেখার সময় যে সময়টি দেখানো উচিত, RFC 3339 অনুযায়ী ফর্ম্যাট করা। এই ব্যবহারকারীর টাইমলাইন ডিসপ্লে টাইম অনুযায়ী ক্রমানুসারে সাজানো হয়, তাই এটি টাইমলাইনে আইটেমটি কোথায় দেখানো হবে তাও নির্ধারণ করবে। পরিষেবা দ্বারা সেট করা না থাকলে, ডিসপ্লে টাইম ডিফল্ট হিসেবে updated টাইম দেখায়। রাইট করা যাবে
html string এই আইটেমের জন্য HTML কন্টেন্ট। কোনও আইটেমের জন্য text এবং html দুটিই প্রদান করা হলে, টাইমলাইনে 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

অন্যান্য এলিমেন্ট: তালিকাভুক্ত নয় এমন যেকোনও এলিমেন্ট সরিয়ে দেওয়া হয়, তবে সেগুলির কন্টেন্ট রেখে দেওয়া হয়।

রাইট করা যাবে
isBundleCover boolean এই আইটেমটি বান্ডেল কভার কিনা।

কোনও আইটেমকে বান্ডেল কভার হিসেবে চিহ্নিত করা হলে, সেটি সেই আইটেমের মতো একই bundleId থাকা আইটেমের বান্ডেলের এন্ট্রি পয়েন্ট হবে। এটি শুধুমাত্র মূল টাইমলাইনে দেখানো হবে — খোলা বান্ডেলের মধ্যে নয়।

প্রধান টাইমলাইনে যেসব আইটেম দেখানো হয় সেগুলি হল:
  • যেসব আইটেমে isBundleCover, true-এ সেট করা আছে
  • যেসব আইটেমে bundleId নেই
বান্ডেল সাব-টাইমলাইনে যেসব আইটেম দেখানো হয়:
  • যেসব আইটেমে bundleId-এর সাথে এবং isBundleCover-এর মান false সেট করা আছে
রাইট করা যাবে
location nested object এই আইটেমের সাথে যুক্ত জিওগ্রাফিক লোকেশন। রাইট করা যাবে
notification nested object এই আইটেমের জন্য বিজ্ঞপ্তি কীভাবে ডিভাইসে দেখানো হবে তা নিয়ন্ত্রণ করে। এটি না থাকলে, কোনও বিজ্ঞপ্তি জেনারেট করা হবে না। রাইট করা যাবে
notification.deliveryTime datetime যে সময়ে বিজ্ঞপ্তিটি ডেলিভার করা উচিত। রাইট করা যাবে
notification.level string বিজ্ঞপ্তিটি কতটা গুরুত্বপূর্ণ তা বর্ণনা করে। অনুমোদিত মানগুলি হল:
  • DEFAULT - ডিফল্ট গুরুত্বের বিজ্ঞপ্তি। ব্যবহারকারীদের সতর্ক করতে একটি চাইম বাজানো হবে।
রাইট করা যাবে
recipients[] list এই আইটেমটি যেসব ব্যবহারকারী বা গ্রুপের সাথে শেয়ার করা হয়েছে তাদের তালিকা। রাইট করা যাবে
sourceItemId string আপনার নিজের পরিষেবায় ডেটাতে টাইমলাইন আইটেম ম্যাপ করতে আপনি অপেক স্ট্রিং ব্যবহার করতে পারবেন। রাইট করা যাবে
speakableText string এই আইটেমের কন্টেন্টের স্পিকেবল ভার্সন। READ_ALOUD মেনু আইটেমের সাথে, এই ফিল্ড ব্যবহার করে এমন টেক্সট প্রদান করুন যা জোরে পড়লে আরও স্পষ্ট হবে অথবা Glass-এ যা দেখা যাচ্ছে তার সম্পর্কে আরও তথ্য প্রদান করুন।

Glassware-এ speakableType ফিল্ডও উল্লেখ করতে হবে, যা অতিরিক্ত প্রসঙ্গ উপযোগী হলে এই টেক্সটের আগে বলা হবে, যেমন ব্যবহারকারী কোনও বিজ্ঞপ্তির পরে আইটেমটি জোরে পড়ার অনুরোধ করলে।
রাইট করা যাবে
speakableType string এই আইটেমের ধরনের একটি স্পিকেবল বিবরণ। অতিরিক্ত প্রসঙ্গ উপযোগী হলে, আইটেমের কন্টেন্ট পড়ার আগে ব্যবহারকারীকে এটি ঘোষণা করা হবে, যেমন ব্যবহারকারী কোনও বিজ্ঞপ্তি অনুসরণ করে আইটেমটি জোরে পড়ার অনুরোধ করলে।

এটি "ইমেল", "টেক্সট মেসেজ" বা "Daily Planet News আপডেট"-এর মতো সংক্ষিপ্ত, সহজ বিশেষ্য পদগুচ্ছ হওয়া উচিত।

Glassware-কে প্রতিটি টাইমলাইন আইটেমের জন্য এই ফিল্ডটি পূরণ করতে উৎসাহিত করা হয়, এমনকি আইটেমটিতে speakableText বা টেক্সট না থাকলেও, যাতে ব্যবহারকারী স্ক্রিনের দিকে না তাকিয়ে আইটেমের ধরন জানতে পারেন।
রাইট করা যাবে
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 ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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
}

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