Timeline: insert

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

টাইমলাইনে একটি নতুন আইটেম সন্নিবেশ করান। একটি উদাহরণ দেখুন

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

  • সর্বাধিক ফাইলের আকার: 10MB
  • গৃহীত মিডিয়া MIME প্রকার: image/* , audio/* , video/*

প্রদান করা হলে, আপলোড করা মিডিয়া টাইমলাইন আইটেমের সাথে সংযুক্তি হিসাবে ঢোকানো হয়।

অনুরোধ

HTTP অনুরোধ

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

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

পরামিতি

পরামিতি নাম মান বর্ণনা
প্রয়োজনীয় ক্যোয়ারী প্যারামিটার
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.client.http.InputStreamContent;
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;
import java.io.InputStream;

public class MyClass {
  // ...

  /**
   * Insert a new timeline item in the user's glass with an optional
   * notification and attachment.
   * 
   * @param service Authorized Mirror service.
   * @param text timeline item's text.
   * @param contentType Optional attachment's content type (supported content
   *        types are "image/*", "video/*" and "audio/*").
   * @param attachment Optional attachment stream.
   * @param notificationLevel Optional notification level, supported values are
   *        {@code null} and "AUDIO_ONLY".
   * @return Inserted timeline item on success, {@code null} otherwise.
   */
  public static TimelineItem insertTimelineItem(Mirror service, String text, String contentType,
      InputStream attachment, String notificationLevel) {
    TimelineItem timelineItem = new TimelineItem();
    timelineItem.setText(text);
    if (notificationLevel != null && notificationLevel.length() > 0) {
      timelineItem.setNotification(new NotificationConfig().setLevel(notificationLevel));
    }
    try {
      if (contentType != null && contentType.length() > 0 && attachment != null) {
        // Insert both metadata and attachment.
        InputStreamContent mediaContent = new InputStreamContent(contentType, attachment);
        return service.timeline().insert(timelineItem, mediaContent).execute();
      } else {
        // Insert metadata only.
        return service.timeline().insert(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>
  /// Insert a new timeline item in the user's glass with an optional
  /// notification and attachment.
  /// </summary>
  /// <param name='service'>Authorized Mirror service.</param>
  /// <param name='text'>Timeline Item's text.</param>
  /// <param name='contentType'>
  /// Optional attachment's content type (supported content types are
  /// "image/*", "video/*" and "audio/*").
  /// </param>
  /// <param name='attachment'>Optional attachment stream</param>
  /// <param name='notificationLevel'>
  /// Optional notification level, supported values are null and
  /// "AUDIO_ONLY".
  /// </param>
  /// <returns>
  /// Inserted timeline item on success, null otherwise.
  /// </returns>
  public static TimelineItem InsertTimelineItem(MirrorService service,
      String text, String contentType, Stream attachment,
      String notificationLevel) {
    TimelineItem timelineItem = new TimelineItem();
    timelineItem.Text = text;
    if (!String.IsNullOrEmpty(notificationLevel)) {
      timelineItem.Notification = new NotificationConfig() {
        Level = notificationLevel
      };
    }
    try {
      if (!String.IsNullOrEmpty(contentType) && attachment != null) {
        // Insert both metadata and media.
        TimelineResource.InsertMediaUpload request = service.Timeline.Insert(
            timelineItem, attachment, contentType);
        request.Upload();
        return request.ResponseBody;
      } else {
        // Insert metadata only.
        return service.Timeline.Insert(timelineItem).Fetch();
      }
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
      return null;
    }
  }

  // ...
}

পিএইচপি

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

/**
 * Insert a new timeline item in the user's glass with an optional
 * notification and attachment.
 *
 * @param Google_MirrorService $service Authorized Mirror service.
 * @param string $text timeline item's text.
 * @param string $contentType Optional attachment's content type (supported
 *                            content types are "image/*", "video/*"
 *                            and "audio/*").
 * @param string $attachment Optional attachment content.
 * @param string $notificationLevel Optional notification level,
 *                                  supported values are {@code null}
 *                                  and "AUDIO_ONLY".
 * @return Google_TimelineItem Inserted timeline item on success, otherwise.
 */
function insertTimelineItem($service, $text, $contentType, $attachment,
                            $notificationLevel) {
  try {
    $timelineItem = new Google_TimelineItem();
    $timelineItem->setText($text);
    if ($notificationlevel != null) {
      $notification = new Google_NotificationConfig();
      $notification->setLevel($notificationLevel);
      $timelineItem->setNotification($notification);
    }
    $optParams = array();
    if ($contentType != null && $attachment != null) {
      $optParams['data'] = $attachment;
      $optParams['mimeType'] = $contentType;
    }
    return $service->timeline->insert($timelineItem, $optParams);
  } catch (Exception $e) {
    print 'An error occurred: ' . $e->getMessage();
    return null;
  }
}

পাইথন

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

import io

from apiclient import errors
from apiclient.http import MediaIoBaseUpload
# ...

def insert_timeline_item(service, text, content_type=None, attachment=None,
                         notification_level=None):
  """Insert a new timeline item in the user's glass.

  Args:
    service: Authorized Mirror service.
    text: timeline item's text.
    content_type: Optional attachment's content type (supported content types
                  are 'image/*', 'video/*' and 'audio/*').
    attachment: Optional attachment as data string.
    notification_level: Optional notification level, supported values are None
                        and 'AUDIO_ONLY'.

  Returns:
    Inserted timeline item on success, None otherwise.
  """
  timeline_item = {'text': text}
  media_body = None
  if notification_level:
    timeline_item['notification'] = {'level': notification_level}
  if content_type and attachment:
    media_body = MediaIoBaseUpload(
        io.BytesIO(attachment), mimetype=content_type, resumable=True)
  try:
    return service.timeline().insert(
        body=timeline_item, media_body=media_body).execute()
  except errors.HttpError, error:
    print 'An error occurred: %s' % error

রুবি

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

##
# Insert a new Timeline Item in the user's glass.
#
# @param [Google::APIClient] client
#   Authorized client instance.
# @param [String] text
#   Timeline item's text.
# @param [String] content_type
#   Optional attachment's content type (supported content types are 'image/*',
#   'video/*' and 'audio/*').
# @param [String] filename
#   Optional attachment's filename.
# @param [String] notification_level
#   Optional notification level, supported values are nil and 'AUDIO_ONLY'.
# @return [Google::APIClient::Schema::Mirror::V1::TimelineItem]
#   Timeline item instance if successful, nil otherwise.
def insert_timeline_item(client, text, content_type, filename,
                         notification_level)
  mirror = client.discovered_api('mirror', 'v1')
  timeline_item = mirror.timeline.insert.request_schema.new({ 'text' => text })
  if notification_level
    timeline_item.notification = { 'level' => notification_level }
  end
  result = nil
  if filename
    media = Google::APIClient::UploadIO.new(filename, content_type)
    result = client.execute(
      :api_method => mirror.timeline.insert,
      :body_object => timeline_item,
      :media => media,
      :parameters => {
        'uploadType' => 'multipart',
        'alt' => 'json'})
  else
    result = client.execute(
      :api_method => mirror.timeline.insert,
      :body_object => timeline_item)
  end
  if result.success?
    return result.data
  else
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

যাওয়া

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

import (
	"code.google.com/p/google-api-go-client/mirror/v1"
	"fmt"
	"io"
)

// InsertTimelineItem inserts a new timeline item in the user's glass with an
// optional notification and attachment.
func InsertTimelineItem(g *mirror.Service, text string, attachment io.Reader,
	notificationLevel string) (*mirror.TimelineItem, error) {
	t := &mirror.TimelineItem{Text: text}
	if notificationLevel != "" {
		t.Notification = &mirror.NotificationConfig{Level: notificationLevel}
	}
	req := g.Timeline.Insert(t)
	if attachment != nil {
		// Add attachment to the timeline item.
		req.Media(attachment)
	}
	r, err := req.Do()
	if err != nil {
		fmt.Printf("An error occurred: %v\n", err)
		return nil, err
	}
	return r, nil
}

কাঁচা HTTP

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

## A very simple timeline item

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

## A more complete timeline item with an attachment

POST /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": "Hello world",
 "menuItems": [
   { "action": "REPLY" },
   {
     "action": "CUSTOM",
     "id": "complete"
     "values": [{
       "displayName": "Complete",
       "iconUrl": "http://example.com/icons/complete.png"
     }]
   }
}
--mymultipartboundary
Content-Type: image/jpeg
Content-Transfer-Encoding: binary

binary image data
--mymultipartboundary--