It seems like the page token expires after 120 minutes... On Wednesday, 12 May 2021 at 09:31:42 UTC+2 Lukas St wrote:
> The error occurs when downloading several millions of keywords that take > around 2 or 3 hours using the google ads PHP library. > The error was already described on this GitHub repo > https://github.com/googleads/google-ads-php/issues/366 > > However, a solution how to refresh the page token when paginating through > the results was not provided, but that's exactly what my system would need. > > Here is part of my code: > $gaql = "SELECT campaign.id, " > . "campaign.name, " > . "ad_group.id, " > . "ad_group.name, " > . "metrics.impressions, " > . "metrics.clicks, " > . "metrics.cost_micros " > . "FROM keyword_view"; > $stream = $this->search($gaql, ['pageSize' => 5000]); > while (true) { > $page = $stream->getPage(); > > foreach ($page->getIterator() as $googleAdsRow) { > // work with data > } > > $nextPageToken = $page->getNextPageToken(); > $stream = $this->search($gaql, ['pageSize' => 5000, 'pageToken' > => $nextPageToken]); > > if ($nextPageToken == false) { > echo "[INFO] There are no more pages" . "\n"; > break; > } > } > > *After running for an hour and more without problems:* > > { > "errors": [{ > "errorCode": { > "requestError": "EXPIRED_PAGE_TOKEN" > }, > "message": "Page token has expired." > }] > } > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/be9fb7d6-ce39-4e6c-a033-d86108d38f8an%40googlegroups.com.