Immediate help on Google Calendat API BULK operations
€25-50 EUR
İptal edildi
İlan edilme: yaklaşık 7 yıl önce
€25-50 EUR
Teslimde ödenir
I NEED IMMEDIATE HELP TO HAVE A PHO SCRIPT CORRECTLY RUNNING
I'm using the PHP library to publish and delete events to a Google calendar via Google API. Everything it is ok when I add or delete a single event.
My problem is if I try to use BATCH operations since I have to add/remove a lot of events. In case of batch operation, I get response (401) Login Required, but the $client it is the same that is perfectly working with single operations.
This creates the client and service
$client2 = new Google_Client();
$client2->setClientId($client_id);
$client2->setClientSecret($client_secret);
$client2->setRedirectUri($redirect_uri);
$client2->setDeveloperKey($oauth2['authToken']);
$service2 = new Google_Service_Calendar($client2)
This for adding single event:
$created = $service->events->import($oauth2['gcalid'], $gevent, $optParams = array());
This for deleting single event:
$service->events->delete($oauth2['gcalid'], $item->getId());
This is the code for BULK operations that are not working.
$client2->setUseBatch(true);
$batch2 = new Google_Http_Batch($client2);
foreach ($items as $item){
echo "Elimino evento " . $item->getId() . "\n";
$req1 = $service2->events->delete($oauth2['gcalid'], $item->getId());
$batch2->add($req1);
}
$results2 = $batch2->execute();
$client->setUseBatch(false);
How could I solve?
Thank you, Michele