승인 필요
타임라인 항목의 첨부파일 목록을 반환합니다. 예를 참조하세요.
요청
HTTP 요청
GET https://www.googleapis.com/mirror/v1/timeline/itemId/attachments
매개변수
| 매개변수 이름 | 값 | 설명 |
|---|---|---|
| 경로 매개변수 | ||
itemId |
string |
첨부파일을 나열해야 하는 타임라인 항목의 ID입니다. |
승인
이 요청을 처리하려면 다음 범위의 승인이 필요합니다 (인증 및 승인 자세히 알아보기).
| 범위 |
|---|
https://www.googleapis.com/auth/glass.timeline |
요청 본문
이 메소드를 사용할 때는 요청 본문을 제공하지 마세요.
응답
요청에 성공할 경우 이 메소드는 다음과 같은 구조의 응답 본문을 반환합니다.
{
"kind": "mirror#attachmentsList",
"items": [
timeline.attachments Resource
]
}
| 속성 이름 | 값 | 설명 | 참고 |
|---|---|---|---|
kind |
string |
리소스 유형 항상 mirror#attachmentsList입니다. |
|
items[] |
list |
첨부파일 목록입니다. |
예
참고: 이 메서드에 제공되는 코드 예시가 지원되는 모든 프로그래밍 언어를 나타내는 것은 아닙니다. 지원되는 언어 목록은 클라이언트 라이브러리 페이지를 참조하세요.
자바
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
##
# 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
원시 HTTP
클라이언트 라이브러리를 사용하지 않습니다.
GET /mirror/v1/timeline/timeline item id/attachments HTTP/1.1 Host: www.googleapis.com Authorization: Bearer auth token