승인 필요
ID별로 단일 타임라인 항목을 가져옵니다. 예를 참조하세요.
이 엔드포인트는 타임라인 항목의 메타데이터를 반환합니다. 타임라인 항목의 첨부파일 콘텐츠를 다운로드하는 방법은 mirror.attachments.get을 참고하세요.
요청
HTTP 요청
GET https://www.googleapis.com/mirror/v1/timeline/id
매개변수
매개변수 이름 | 값 | 설명 |
---|---|---|
경로 매개변수 | ||
id |
string |
타임라인 항목의 ID입니다. |
승인
이 요청에는 다음 범위 중 최소 하나를 사용하여 인증이 필요합니다. (인증 및 승인에 대해 자세히 알아보기)
범위 |
---|
https://www.googleapis.com/auth/glass.timeline |
https://www.googleapis.com/auth/glass.location |
요청 본문
이 메소드를 사용할 때는 요청 본문을 제공하지 마세요.
응답
요청에 성공할 경우 이 메서드는 응답 본문에 타임라인 리소스를 반환합니다.
예
참고: 이 메서드에 제공되는 코드 예시가 지원되는 모든 프로그래밍 언어를 나타내는 것은 아닙니다. 지원되는 언어 목록은 클라이언트 라이브러리 페이지를 참조하세요.
자바
Java 클라이언트 라이브러리를 사용합니다.
import com.google.api.services.mirror.Mirror; import com.google.api.services.mirror.model.Attachment; import com.google.api.services.mirror.model.Contact; import com.google.api.services.mirror.model.NotificationConfig; import com.google.api.services.mirror.model.TimelineItem; import java.io.IOException; public class MyClass { // ... /** * Print some timeline item metadata information. * * @param service Authorized Mirror service. * @param itemId ID of the timeline item to print metadata information for. */ public static void printTimelineItemMetadata(Mirror service, String itemId) { try { TimelineItem timelineItem = service.timeline().get(itemId).execute(); System.out.println("Timeline item ID: " + timelineItem.getId()); if (timelineItem.getIsDeleted()) { System.out.println("Timeline item has been deleted"); } else { Contact creator = timelineItem.getCreator(); if (creator != null) { System.out.println("Timeline item created by " + creator.getDisplayName()); } System.out.println("Timeline item created on " + timelineItem.getCreated().toStringRfc3339()); System.out.println("Timeline item displayed on " + timelineItem.getDisplayTime().toStringRfc3339()); String inReplyTo = timelineItem.getInReplyTo(); if (inReplyTo != null && inReplyTo.length() > 0) { System.out.println("Timeline item is a reply to " + inReplyTo); } String text = timelineItem.getText(); if (text != null && text.length() > 0) { System.out.println("Timeline item has text: " + text); } for (Contact contact : timelineItem.getRecipients()) { System.out.println("Timeline item is shared with: " + contact.getId()); } NotificationConfig notification = timelineItem.getNotification(); if (notification != null) { System.out.println("Notification delivery time: " + notification.getDeliveryTime().toStringRfc3339()); System.out.println("Notification level: " + notification.getLevel()); } // See mirror.timeline.attachments.get to learn how to download the attachment's content. for (Attachment attachment : timelineItem.getAttachments()) { System.out.println("Attachment ID: " + attachment.getId()); System.out.println(" > Content-Type: " + attachment.getContentType()); } } } catch (IOException e) { System.err.println("An error occurred: " + e); } } // ... }
.NET
.NET 클라이언트 라이브러리를 사용합니다.
using System; using Google.Apis.Mirror.v1; using Google.Apis.Mirror.v1.Data; public class MyClass { // ... /// <summary> /// Print some timeline item metadata information. /// </summary> /// <param name='service'>Authorized Mirror service.</param> /// <param name='itemId'> /// ID of the timeline item to print metadata information for. /// </param> public static void PrintTimelineItemMetadata(MirrorService service, String itemId) { try { TimelineItem timelineItem = service.Timeline.Get(itemId).Fetch(); Console.WriteLine("Timeline item ID: " + timelineItem.Id); if (timelineItem.IsDeleted.HasValue && timelineItem.IsDeleted.Value) { Console.WriteLine("Timeline item has been deleted"); } else { Contact creator = timelineItem.Creator; if (creator != null) { Console.WriteLine("Timeline item created by " + creator.DisplayName); } Console.WriteLine("Timeline item created on " + timelineItem.Created); Console.WriteLine( "Timeline item displayed on " + timelineItem.DisplayTime); String inReplyTo = timelineItem.InReplyTo; if (!String.IsNullOrEmpty(inReplyTo)) { Console.WriteLine("Timeline item is a reply to " + inReplyTo); } String text = timelineItem.Text; if (!String.IsNullOrEmpty(text)) { Console.WriteLine("Timeline item has text: " + text); } foreach (Contact contact in timelineItem.Recipients) { Console.WriteLine("Timeline item is shared with: " + contact.Id); } NotificationConfig notification = timelineItem.Notification; if (notification != null) { Console.WriteLine( "Notification delivery time: " + notification.DeliveryTime); Console.WriteLine("Notification level: " + notification.Level); } // See mirror.timeline.attachments.get to learn how to download the // attachment's content. foreach (Attachment attachment in timelineItem.Attachments) { Console.WriteLine("Attachment ID: " + attachment.Id); Console.WriteLine(" > Content-Type: " + attachment.ContentType); } } } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); } } // ... }
PHP
PHP 클라이언트 라이브러리를 사용합니다.
/** * Print some timeline item metadata information. * * @param Google_MirrorService $service Authorized Mirror service. * @param string $itemId ID of the timeline item to print metadata * information for. */ function printTimelineItemMetadata($service, $itemId) { try { $timelineItem = $service->timeline->get($itemId); print 'Timeline item ID: ' . $timelineItem->getId(); if ($timelineItem->getIsDeleted()) { print 'Timeline item has been deleted'; } else { $creator = $timelineItem->getCreator(); if ($creator != null) { print 'Timeline item created by ' . $creator->getDisplayName(); } print 'Timeline item created on ' . $timelineItem->getCreated(); print 'Timeline item displayed on ' . $timelineItem->getDisplayTime(); $inReplyTo = $timelineItem->getInReplyTo(); if ($inReplyTo != null) { print 'Timeline item is a reply to ' . $inReplyTo; } $text = $timelineItem->getText(); if ($text != null) { print 'Timeline item has text: ' . $text; } else { foreach ($timelineItem->getHtml() as $html) { print 'Timeline item has HTML: ' . $html; } } foreach ($timelineItem->getRecipients() as $contacts) { print 'Timeline item is shared with: ' . $contact->getId(); } $notification = $timelineItem->getNotification(); if ($notification != null) { print 'Notification delivery time: ' . $notification->getDeliveryTime(); print 'Notification level: ' . $notification->getLevel(); } } } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); } }
Python
Python 클라이언트 라이브러리를 사용합니다.
from apiclient import errors # ... def print_timeline_item_metadata(service, timeline_id): """Print some timeline item metadata information. Args: service: Authorized Mirror service. item_id: ID of the timeline item to print metadata information for. """ try: timeline_item = service.timeline().get(id=item_id).execute() print 'Timeline item ID: %s' % timeline_item.get('id') if timeline_item.get('isDeleted'): print 'Timeline item has been deleted' else: creator = timeline_item.get('creator') if creator: print 'Timeline item created by %s' % creator.get('displayName') print 'Timeline item created on %s' % timeline_item.get('created') print 'Timeline item displayed on %s' % timeline_item.get('displayTime') in_reply_to = timeline_item.get('inReplyTo') if in_reply_to: print 'Timeline item is a reply to %s' % in_reply_to text = timeline_item.get('text') if text: print 'Timeline item has text: %s' % text for contact in timeline_item.get('recipients', []): print 'Timeline item is shared with: %s' % contact.get('id') notification = timeline_item.get('notification') if notification: print 'Notification delivery time: %s' % ( notification.get('deliveryTime')) print 'Notification level: %s' % notification.get('level') # See mirror.timeline.attachments.get to learn how to download the # attachment's content. for attachment in timeline_item.get('attachments', []): print 'Attachment ID: %s' % attachment.get('id') print ' > Content-Type: %s' % attachment.get('contentType') except errors.HttpError, error: print 'An error occurred: %s' % error
Ruby
### # Print some Timeline Item metadata information. # # @param [Google::APIClient] client # Authorized client instance. # @param [string] item_id # ID of the timeline item to print metadata information for. # @return nil def print_timeline_item_metadata(client, item_id) 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 puts "Timeline item ID: #{timeline_item.id}" if timeline_item.is_deleted puts "Timeline item has been deleted" else creator = timeline_item.creator if creator puts "Timeline item created by #{creator.display_name}" end puts "Timeline created on #{timeline_item.created}" puts "Timeline displayed on #{timeline_item.display_time}" in_reply_to = timeline_item.in_reply_to if in_reply_to puts "Timeline item is a reply to #{in_reply_to}" end text = timeline_item.text if text puts "Timeline item has text: #{text}" end html = timeline_item.html if html puts "Timeline item has html: #{html}" end timeline_item.recipients.each do |contact| puts "Timeline item is shared with: #{contact.id}" end notification = timeline_item.notification if notification puts "Notification delivery time: #{notification.delivery_time}" puts "Notification level: #{notification.level}" end end else puts "An error occurred: #{result.data['error']['message']}" end end
Go
Go 클라이언트 라이브러리를 사용합니다.
import ( "code.google.com/p/google-api-go-client/mirror/v1" "fmt" ) // PrintTimelineItemMetadata some timeline item metadata information. func PrintTimelineItemMetadata(g *mirror.Service, itemId string) error { t, err := g.Timeline.Get(itemId).Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return err } fmt.Printf("Timeline item ID: %s\n", t.Id) if t.IsDeleted { fmt.Printf("Timeline item has been deleted\n") } else { if t.Creator != nil { fmt.Printf("Timeline item created by %s\n", t.Creator.DisplayName) } fmt.Printf("Timeline item created on %s\n", t.Created) fmt.Printf("Timeline item displayed on %s\n", t.DisplayTime) if t.InReplyTo != "" { fmt.Printf("Timeline item is a reply to %s\n", t.InReplyTo) } if t.Text != "" { fmt.Printf("Timeline item has text: %s\n", t.Text) } for _, s := range t.Recipients { fmt.Printf("Timeline item is shared with: %s\n", s.Id) } if t.Notification != nil { n := t.Notification fmt.Printf("Notification delivery time: %s\n", n.DeliveryTime) fmt.Printf("Notification level: %s\n", n.Level) } for _, a := range t.Attachments { fmt.Printf("Attachment ID: %s\n", a.Id) fmt.Printf(" > Content-Type: %s\n", a.ContentType) } } return nil }
원시 HTTP
클라이언트 라이브러리를 사용하지 않습니다.
GET /mirror/v1/timeline HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer auth token