Wymaga autoryzacji
Pobiera jeden element osi czasu według identyfikatora. Zobacz przykład
Ten punkt końcowy zwraca metadane elementu osi czasu. Na stronie mirror.attachments.get dowiesz się, jak pobrać zawartość załączników elementu osi czasu.
Żądanie
Żądanie HTTP
GET https://www.googleapis.com/mirror/v1/timeline/id
Parametry
Nazwa parametru | Wartość | Opis |
---|---|---|
Parametry ścieżki | ||
id |
string |
Identyfikator elementu osi czasu. |
Autoryzacja
To żądanie wymaga autoryzacji przy użyciu co najmniej 1 z tych zakresów (więcej informacji o uwierzytelnianiu i autoryzacji).
Zakres |
---|
https://www.googleapis.com/auth/glass.timeline |
https://www.googleapis.com/auth/glass.location |
Treść żądania
Nie podawaj treści żądania przy użyciu tej metody.
Odpowiedź
Jeśli operacja się uda, metoda zwróci zasób na osi czasu w treści odpowiedzi.
Przykłady
Uwaga: dostępne dla tej metody przykłady kodu nie odzwierciedlają wszystkich obsługiwanych języków programowania. Listę obsługiwanych języków znajdziesz na stronie z bibliotekami klienta.
Java
Używa biblioteki klienta 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
Używa biblioteki klienta.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
Używa biblioteki klienta 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
Używa biblioteki klienta w Pythonie.
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
Używa biblioteki klienta 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
Przeczytaj
Używa biblioteki klienta 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 }
Nieprzetworzony kod HTTP
Nie korzysta z biblioteki klienta.
GET /mirror/v1/timeline HTTP/1.1
Host: www.googleapis.com
Authorization: Bearer auth token