Opensocial suports pagination by providing developers the ability to add startIndex
and count
parameters to DataRequests ( and other *Requests). If developer does not supply a count
parameters, its detault is 20
, and as you guess, when a startIndex
parameter isnt supplied, it defautls to 0(zero)
.
Response you get must be something like:
{
"startIndex": 0,
"totalResults": 120,
"entry": [
....
]
}
Here, totalResults
is the total number of albums, not the returned album count.
You can use totalResults
to calculate your page count and prepare your pagination.
Update:
opensocial.DataRequest.MediaItemsField.MAX field probably used while making MediaItemRequests, however to make a album list AlbumRequest should be used.
you can limit the number of albums fetched in this pipeline
<os:AlbumsRequest key='myalbums' userid="@viewer" groupid="@self" />
by adding a count
parameter, such as:
<os:AlbumsRequest key='myalbums' userid="@viewer" groupid="@self" count="5"/>
this album request fetches at max 5 albums of viewer.
the resulting json would be:
{
"startIndex": 0,
"totalResults": ....here total number of albums....,
"entry": [
....here at max 5 albums....
]
}
Here you can get total number of album by calling myalbums.totalResults
.