Timeline: update

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

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

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

  • সর্বাধিক ফাইলের আকার: 10MB
  • গৃহীত মিডিয়া 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 /আপলোড 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 পেলোড থেকে সরানো হয়।

  • ডকুমেন্ট হেডার: 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 মেনু আইটেমের সাথে, এই ক্ষেত্রটি ব্যবহার করুন পাঠ্য প্রদানের জন্য যা উচ্চস্বরে পড়ার সময় স্পষ্ট হবে, অথবা গ্লাসে যা দৃশ্যমানভাবে প্রদর্শিত হবে তার জন্য বর্ধিত তথ্য প্রদান করতে।

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

এটি একটি সংক্ষিপ্ত, সাধারণ বিশেষ্য বাক্যাংশ যেমন "ইমেল", "টেক্সট বার্তা" বা "ডেইলি প্ল্যানেট নিউজ আপডেট" হওয়া উচিত।

গ্লাসওয়্যারকে প্রতিটি টাইমলাইন আইটেমের জন্য এই ক্ষেত্রটি পপুলেট করার জন্য উত্সাহিত করা হয়, এমনকি যদি আইটেমটিতে কথা বলার যোগ্য পাঠ্য বা পাঠ্য না থাকে যাতে ব্যবহারকারী পর্দার দিকে না তাকিয়ে আইটেমের ধরণটি শিখতে পারে।
লিখনযোগ্য
text string এই আইটেমটির পাঠ্য বিষয়বস্তু। লিখনযোগ্য
title string এই আইটেম শিরোনাম. লিখনযোগ্য

প্রতিক্রিয়া

সফল হলে, এই পদ্ধতিটি প্রতিক্রিয়া বডিতে একটি টাইমলাইন সংস্থান প্রদান করে।

উদাহরণ

দ্রষ্টব্য: এই পদ্ধতির জন্য উপলব্ধ কোড উদাহরণগুলি সমস্ত সমর্থিত প্রোগ্রামিং ভাষার প্রতিনিধিত্ব করে না (সমর্থিত ভাষার তালিকার জন্য ক্লায়েন্ট লাইব্রেরি পৃষ্ঠা দেখুন)।

জাভা

জাভা ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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 ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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

  // ...
}

পিএইচপি

পিএইচপি ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

/**
 * 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;
  }
}

পাইথন

পাইথন ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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

রুবি

রুবি ক্লায়েন্ট লাইব্রেরি ব্যবহার করে।

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

কাঁচা 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" }