Timeline.attachments: list

इसके लिए, अनुमति देना ज़रूरी है

समयावधि आइटम के लिए अटैचमेंट की सूची लौटाता है. उदाहरण देखें.

अनुरोध करें

एचटीटीपी अनुरोध

GET https://www.googleapis.com/mirror/v1/timeline/itemId/attachments

पैरामीटर

पैरामीटर का नाम वैल्यू ब्यौरा
पाथ पैरामीटर
itemId string टाइमलाइन आइटम का वह आईडी जिसके अटैचमेंट की सूची बनाई जानी चाहिए.

अनुमति देना

इस अनुरोध को नीचे दिए गए दायरे के साथ अनुमति देना ज़रूरी है (पुष्टि करने और मंज़ूरी देने के बारे में ज़्यादा पढ़ें).

स्कोप
https://www.googleapis.com/auth/glass.timeline

अनुरोध का मुख्य भाग

इस तरीके से, अनुरोध का मुख्य हिस्सा न दें.

जवाब

अगर अनुरोध कामयाब रहता है, तो इस रिस्पॉन्स के साथ रिस्पॉन्स का फ़ॉर्मैट नीचे दिया गया है:

{
  "kind": "mirror#attachmentsList",
  "items": [
    timeline.attachments Resource
  ]
}
प्रॉपर्टी का नाम वैल्यू ब्यौरा ज़रूरी जानकारी
kind string संसाधन किस तरह का है. यह संख्या हमेशा mirror#attachmentsList होती है.
items[] list अटैचमेंट की सूची.

उदाहरण

ध्यान दें: इस तरीके के लिए दिए गए कोड के उदाहरणों में इसके साथ काम करने वाली सभी प्रोग्रामिंग भाषाएं नहीं दिखाई गई हैं (इसके साथ काम करने वाली भाषाओं की सूची के लिए क्लाइंट लाइब्रेरी वाला पेज देखें).

Java

Java क्लाइंट लाइब्रेरी का इस्तेमाल करता है.

import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.Attachment;
import com.google.api.services.mirror.model.AttachmentsListResponse;

import java.io.IOException;

public class MyClass {
  // ...

  /**
   * Print all attachments' metadata.
   * 
   * @param service Authorized Mirror service.
   * @param itemId ID of the timeline item the attachments belong to.
   */
  public static void printAllAttachmentsMetadata(Mirror service, String itemId) {
    try {
      AttachmentsListResponse attachments = service.timeline().attachments().list(itemId).execute();

      for (Attachment attachment : attachments.getItems()) {
        System.out.println("Attachment content type: " + attachment.getContentType());
        System.out.println("Attachment content URL: " + attachment.getContentUrl());
      }
    } catch (IOException e) {
      System.out.println("An error occured: " + e);
    }

  }

  // ...
}

.NET

.NET क्लाइंट लाइब्रेरी का इस्तेमाल करता है.

using System;
using Google.Apis.Mirror.v1;
using Google.Apis.Mirror.v1.Data;

public class MyClass {
  // ...

  /// <summary>
  /// Print all attachments' metadata.
  /// </summary>
  /// <param name="service">Authorized Mirror service.</param>
  /// <param name="itemId">ID of the timeline item the attachments belong to.</param>
  public static void PrintAllAttachmentsMetadata(MirrorService service, String itemId) {
    try {
      AttachmentsListResponse attachments = service.Timeline.Attachments.List(itemId).Fetch();

      foreach (Attachment attachment in attachments.Items) {
        Console.WriteLine("Attachment content type: " + attachment.ContentType);
        Console.WriteLine("Attachment content URL: " + attachment.ContentUrl);
      }
    } catch (Exception e) {
      Console.WriteLine("An error occurred: " + e.Message);
    }
  }

  // ...
}

PHP

PHP क्लाइंट लाइब्रेरी का इस्तेमाल करता है.

/**
 * Print all attachments' metadata.
 *
 * @param Google_MirrorService $service Authorized Mirror service.
 * @param string $itemId ID of the timeline item the attachments belong to.
 */
function printAllAttachmentsMetadata($service, $itemId) {
  try {
    $attachments = $service->timeline_attachments->listTimelineAttachments(
        $itemId);

    foreach ($attachments->getItems() as $attachment) {
      print "Attachment content type: " . $attachment->getContentType() . "\n";
      print "Attachment content URL: " . $attachment->getContentUrl() . "\n";
    }
  } catch (Exception $e) {
    print "An error occurred: " . $e->getMessage();
  }
}

Python

Python क्लाइंट लाइब्रेरी का इस्तेमाल करता है.

from apiclient import errors
# ...

def print_all_attachments_metadata(service, item_id):
  """Print all attachments' metadata.

  Args:
    service: Authorized Mirror service.
    item_id: ID of the timeline item the attachments belong to.
  """
  try:
    attachments = service.timeline().attachments().list(
        itemId=item_id).execute()
    for attachment in attachments.get('items', []):
      print 'Attachment content type: %s' % attachment['contentType']
      print 'Attachment content URL: %s' % attachment['contentUrl']
  except errors.HttpError, error:
    print 'An error occurred: %s' % error

Ruby

Ruby क्लाइंट लाइब्रेरी का इस्तेमाल करता है.

##
# Print all attachments' metadata.
#
# @param [Google::APIClient] client
#   Authorized client instance.
# @param [String] item_id
#   ID of the timeline item the attachments belong to.
# @return nil
def print_all_attachments_metadata(client, item_id)
  mirror = client.discovered_api('mirror', 'v1')
  result = client.execute(
    :api_method => mirror.timeline.attachments.list,
    :parameters => { 'itemId' => item_id })
  if result.success?
    attachments = result.data
    attachments.items.each do |attachment|
      puts "Attachment content type: #{attachment.content_type}"
      puts "Attachment content URL: #{attachment.content_url}"
    end
  else
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

रॉ एचटीटीपी

क्लाइंट लाइब्रेरी का इस्तेमाल नहीं करता.

GET /mirror/v1/timeline/timeline item id/attachments HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer auth token