php - Implementing full sync with gmail api -


i use google php library works gmail api. want messages gmail account.

that's how that:

        {             $this->client->setusebatch(false);             $messagesresponse = $service->users_messages->listusersmessages('me', compact('pagetoken'));              if ($messagesresponse->getmessages()) {                 $batch = new google_http_batch($this->client);                 $this->client->setusebatch(true);                  foreach ($messagesresponse $item) {                     $request = $service->users_messages->get('me', $item->id, ['format' => 'raw']);                     $batch->add($request);                 }                  $messages = array_merge($messages, $batch->execute());                 $pagetoken = $messagesresponse->getnextpagetoken();             }         } while ($pagetoken); 

when run script cli got following error:

[google_io_exception]
operation timed out after 100000 milliseconds 57157107 bytes received

if comment line retrieving new token got first 100 messages , works. can't fetch of them. php doesn't have timeout, google_io_exception, don't know how solve problem. plus optimization tips great, since thing i'm aware of batch requests, use them.

this question still relevant, , took me lot of time have clear answer i'll share i've found:

you're limited 100 calls in single batch request. if need make more calls that, use multiple batch requests.

https://developers.google.com/gmail/api/guides/

as can see in, based on documentation cannot have more 100 calls in single batch request. have therefore count , execute below limit.

if maintain limit of 100 requests, should working fine.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -