逐頁瀏覽資源清單
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
您可以設定 maxResults
欄位,控管伺服器在清單要求的回應中傳回的資源數量上限。此外,對於某些集合 (例如「事件」),伺服器永遠不會超過擷取項目的硬性限制。如果事件總數超過這個上限,伺服器會傳回一頁結果。
請注意,maxResults
無法保證單一頁面的結果數。如果結果中的 nextPageToken
欄位不為空,就表示結果不完整。如要擷取下一頁,請執行與先前完全相同的要求,並附加 pageToken
欄位,其值為前一頁的 nextPageToken
。在擷取所有結果之前,系統會在下列頁面提供新的 nextPageToken
。
舉例來說,以下查詢會擷取分頁清單中下一頁的結果:
GET /calendars/primary/events?maxResults=10&singleEvents=true
//Result contains
"nextPageToken":"CiAKGjBpNDd2Nmp2Zml2cXRwYjBpOXA",
後續查詢會從 nextPageToken
取得值,並以 pageToken
的值提交:
GET /calendars/primary/events?maxResults=10&singleEvents=true&pageToken=CiAKGjBpNDd2Nmp2Zml2cXRwYjBpOXA
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["# Page through lists of resources\n\nYou can control the maximum number of resources the server returns in the\nresponse to a list request by setting the `maxResults` field. Furthermore,\nfor some collections (such as Events) there is a hard limit on the number of\nretrieved entries that the server will never exceed. If the total number of\nevents exceeds this maximum, the server returns one page of results.\n\nRemember that `maxResults` does not guarantee the number of results on one page.\nIncomplete results can be detected by a non-empty `nextPageToken` field in\nthe result. In order to retrieve the next page, perform the exact same request\nas previously and append a `pageToken` field with the value of\n`nextPageToken` from the previous page. A new `nextPageToken` is provided\non the following pages until all the results are retrieved.\n\nFor example, here is a query followed by the query for retrieving the\nnext page of results in a paginated list: \n\n GET /calendars/primary/events?maxResults=10&singleEvents=true\n\n //Result contains\n\n \"nextPageToken\":\"CiAKGjBpNDd2Nmp2Zml2cXRwYjBpOXA\",\n\nThe subsequent query takes the value from `nextPageToken` and\nsubmits it as the value for `pageToken`: \n\n GET /calendars/primary/events?maxResults=10&singleEvents=true&pageToken=CiAKGjBpNDd2Nmp2Zml2cXRwYjBpOXA"]]