Google Calendar API Batch Request PHP

PHP multiple events sending

The method you would be using is events.insert this method Creates an event as in singular there is no way to send a request that would send more than one.

You could use batching but all batching really is is sending X number of event.inserts in a single batch request. Its not going to save you on quota the quota cost will be the same the only thing it will save you on is on the number of HTTP calls you are making.

Global HTTP Batch Endpoints (www.googleapis.com/batch) will cease to work on August 12, 2020 as announced on the Google Developers blog. For instructions on transitioning services to use API-specific HTTP Batch Endpoints (www.googleapis.com/batch/api/version), refer to the blog post.

The above statment does not mean that batching doesnt work. It just means that the old batching endpoint which worled for every API no longer works now you need to send batching requests to each api

  • www.googleapis.com/batch/drive/v3
  • www.googleapis.com/batch/calendar/v3

you used to be able to send all batching requests no matter what api you were working with to

  • www.googleapis.com/batch

That no longer works.

How to send batch request with Google Indexing API

I tried with PHP and completed.

   //init google client
$client = new Google_Client();
$client->setAuthConfig('your_path_to_key.json');
$client->addScope('https://www.googleapis.com/auth/indexing');
$client->setUseBatch(true);

//init google batch and set root URL
$batch = new Google_Http_Batch($client,false,'https://indexing.googleapis.com');

//init service Notification to sent request
$postBody = new Google_Service_Indexing_UrlNotification();
$postBody->setType('URL_UPDATED');
$postBody->setUrl('https://your_job_detail');

//init service Indexing ( like updateJobPosting )
$service = new Google_Service_Indexing($client);
//create request
//$service->urlNotifications->createRequestUri('https://indexing.googleapis.com/batch');
$request_kame = $service->urlNotifications->publish($postBody);
//add request to batch
$batch ->add($request_kame);


Related Topics



Leave a reply



Submit