pagination information (php)

Any Core Reporting API request might match hundreds of thousands of rows of Google Analytics data. The Core Reporting API will only return a subset at a given time, which can be referred to as a single page of data. You use the pagination fields to retrieve all pages of data. The totalResults field represents the total number of rows of data that your query matched in Google Analytics. This can be greater than the actual number of rows returned in a single page of the response. The itemsPerPage field represents the number of rows returned in this page. The previousLink and nextLink parameters are only present if there exists a previous or next page. Check these links to see if more pages of data can be retrieved from the Core Reporting API.

private function getPaginationInfo(&$results) {
  $html = <<
Items per page = {$results->getItemsPerPage()}
Total results  = {$results->getTotalResults()}
Previous Link  = {$results->getPreviousLink()}
Next Link      = {$results->getNextLink()}
HTML;

  print $html;
}