Requires authorization
Retrieves a list of timeline items for the authenticated user. See an example.
Request
HTTP request
GET https://www.googleapis.com/mirror/v1/timeline
Parameters
Parameter name | Value | Description |
---|---|---|
Optional query parameters | ||
bundleId |
string |
If provided, only items with the given bundleId will be returned. |
includeDeleted |
boolean |
If true, tombstone records for deleted items will be returned. |
maxResults |
unsigned integer |
The maximum number of items to include in the response, used for paging. |
orderBy |
string |
Controls the order in which timeline items are returned.
Acceptable values are:
|
pageToken |
string |
Token for the page of results to return. |
pinnedOnly |
boolean |
If true, only pinned items will be returned. |
sourceItemId |
string |
If provided, only items with the given sourceItemId will be returned. |
Authorization
This request requires authorization with at least one of the following scopes (read more about authentication and authorization).
Scope |
---|
https://www.googleapis.com/auth/glass.timeline |
https://www.googleapis.com/auth/glass.location |
Request body
Do not supply a request body with this method.
Response
If successful, this method returns a response body with the following structure:
{ "kind": "mirror#timeline", "nextPageToken": string, "items": [ timeline Resource ] }
Property name | Value | Description | Notes |
---|---|---|---|
kind |
string |
The type of resource. This is always mirror#timeline . |
|
nextPageToken |
string |
The next page token. Provide this as the pageToken parameter in the request to retrieve the next page of results. |
|
items[] |
list |
Items in the timeline. |
Examples
Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).
Java
Uses the Java client library.
import com.google.api.services.mirror.Mirror; import com.google.api.services.mirror.Mirror.Timeline; import com.google.api.services.mirror.model.TimelineItem; import com.google.api.services.mirror.model.TimelineListResponse; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class MyClass { // ... /** * Retrieve all timeline items for the current user. * * @param service Authorized Mirror service. * @return Collection of timeline items on success, {@code null} otherwise. */ public static List<TimelineItem> retrieveAllTimelineItems(Mirror service) { List<TimelineItem> result = new ArrayList<TimelineItem>(); try { Timeline.List request = service.timeline().list(); do { TimelineListResponse timelineItems = request.execute(); if (timelineItems.getItems() != null && timelineItems.getItems().length() > 0) { result.addAll(timelineItems.getItems()); request.setPageToken(timelineItems.getNextPageToken()); } else { break; } } while (request.getPageToken() != null && request.getPageToken().length() > 0); } catch (IOException e) { System.err.println("An error occurred: " + e); return null; } return result; } // ... }
.NET
Uses the .NET client library.
using System; using System.Collections.Generic; using Google.Apis.Mirror.v1; using Google.Apis.Mirror.v1.Data; public class MyClass { // ... /// <summary> /// Retrieve all timeline items for the current user. /// </summary> /// <param name='service'>Authorized Mirror service.</param> /// <returns> /// List of timeline items on success, null otherwise. /// </returns> public static List<TimelineItem> RetrieveAllTimelineItems( MirrorService service) { List<TimelineItem> result = new List<TimelineItem>(); try { TimelineResource.ListRequest request = service.Timeline.List(); do { TimelineListResponse timelineItems = request.Fetch(); if (timelineItems.Items != null && timelineItems.Items.Length > 0) { result.AddRange(timelineItems.Items); request.PageToken = timelineItems.NextPageToken; } else { break; } } while (!String.IsNullOrEmpty(request.PageToken)); } catch (Exception e) { Console.WriteLine("An error occurred: " + e.Message); return null; } return result; } // ... }
PHP
Uses the PHP client library.
/** * Retrieve all timeline items for the current user. * * @param Google_MirrorService $service Authorized Mirror service. * @return Array List of Google_TimelineItem resources on success, * null otherwise. */ function retrieveAllTimelineItems($service) { try { $result = array(); $pageToken = null; do { $optParams = array(); if ($pageToken) { $optParams['pageToken'] = $pageToken; } $timelineItems = $service->timeline->listTimeline($optParams); if (!empty(timelineItems->getItems()) { $result = array_merge($result, $timelineItems->getItems()); $pageToken = $timelineItems->getNextPageToken(); } else { break; } } while ($pageToken); return $result; } catch (Exception $e) { print 'An error occurred: ' . $e->getMessage(); return null; } }
Python
Uses the Python client library.
from apiclient import errors # ... def retrieve_all_timeline_tems(service): """Retrieve all timeline items for the current user. Args: service: Authorized Mirror service. Returns: Collection of timeline items on success, None otherwise. """ result = [] request = service.timeline().list() while request: try: timeline_items = request.execute() items = timeline_items.get('items', []) if items: result.extend(timeline_items.get('items', [])) request = service.timeline().list_next(request, timeline_items) else: # No more items to retrieve. break except errors.HttpError, error: print 'An error occurred: %s' % error break return result
Ruby
Uses the Ruby client library.
## # Retrieve all Timeline Items for the current user. # # @param [Google::APIClient] client # Authorized client instance. # @return [Array] # List of timeline items. def retrieve_all_timeline_items(client) mirror = client.discovered_api('mirror', 'v1') result = Array.new page_token = nil begin parameters = {} if page_token.to_s != '' parameters['pageToken'] = page_token end api_result = client.execute( :api_method => mirror.timeline.list, :parameters => parameters) if api_result.success? timeline_items = api_result.data if timeline_items.items.empty? page_token = nil else result.concat(timeline_items.items) page_token = timeline_items.next_page_token end else puts "An error occurred: #{result.data['error']['message']}" page_token = nil end end while page_token.to_s != '' result end
Go
Uses the Go client library.
import ( "code.google.com/p/google-api-go-client/mirror/v1" "fmt" ) // RetrieveAllTimelineItems retrieves all timeline items for the current user. func RetrieveAllTimelineItems(g *mirror.Service) ([]*mirror.TimelineItem, error) { r := []*mirror.TimelineItem{} req := g.Timeline.List() for req != nil { t, err := req.Do() if err != nil { fmt.Printf("An error occurred: %v\n", err) return nil, err } if t.Items != nil && len(t.Items) > 0 { r = append(r, t.Items...) req.PageToken(t.NextPageToken) } else { req = nil } } return r, nil }
Raw HTTP
Does not use a client library.
GET /mirror/v1/timeline HTTP/1.1 Host: www.googleapis.com Authorization: Bearer auth token