php - Google Glass Mirror Service: list timeline items and paging -
i'm trying paginate timeline items can returned in mirror service (i'm using php quickstart example can found here )
from google_mirrorservice.php
file, can read:
/** * retrieves list of timeline items authenticated user. * (timeline.list) * * @param array $optparams optional parameters. * * @opt_param string bundleid if provided, items given bundleid returned. * @opt_param bool includedeleted if true, tombstone records deleted items returned. * @opt_param string maxresults maximum number of items include in response, used paging. * @opt_param string orderby controls order in timeline items returned. * @opt_param string pagetoken token page of results return. * @opt_param bool pinnedonly if true, pinned items returned. * @opt_param string sourceitemid if provided, items given sourceitemid returned. * @return google_timelinelistresponse */ public function listtimeline($optparams = array()) { $params = array(); $params = array_merge($params, $optparams); $data = $this->__call('list', array($params)); if ($this->useobjects()) { return new google_timelinelistresponse($data); } else { return $data; } }
the params same can found here, more or less same description.
from description, understand maxresults
'page size', , pagetoken
'page number'. right first param, not second: seems ignored in request.
so, questions are:
1) pagetoken for?
2) how can paginate timeline items? e.g. getting results 10 19, instead 0 9 only.
the timeline.list
endpoint doesn't support random access of timeline, support iterating on timeline items available result query. if specify maxresults
, no more many results sent back. results sent include array of items , nextpagetoken
attribute.
if need go next page of results, include pagetoken
parameter set result of nextpagetoken
attribute previous call.
see https://developers.google.com/glass/v1/reference/timeline/list example of doing paginated query.
update:
to clear (and answer question in comment), nextpagetoken
should treated opaque - has no meaning except pass server next page.
similarly, there no previouspagetoken
or other way set next bundle want is. in general, these more rare anyway. 1 doesn't need manually flip between pages of results on server - , google's server doesn't overwhelmed if there tons of results on query.
Comments
Post a Comment