-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send batch indexing requests using PHP(forming homogeneous batch requests) #1567
Comments
Hey @bochuanWorkland! Sorry we haven't got an answer to you yet. I added some code formatting to your comment to help make it easier to read. I'll start looking into your issue and see if I can find out what's going on. |
i'm also having this issue. The default endpoint is no longer correct. And it's not really documented how and where to find the new one. In order to do batch results for the youtube api i have to do this: The batch path plus the service path seem to be the same not sure if this is just coincidence; |
The default api base path of $client->setConfig('base_path', 'https://indexing.googleapis.com'); Or create a batch instance by $client = new \Google_Client();
$client->setAuthConfig('/var/www/html/privateKey.json');
$client->addScope('https://www.googleapis.com/auth/indexing');
$client->setUseBatch(true);
$service = new \Google_Service_Indexing($client);
$batch = $service->createBatch();
// add request
$postBody = new \Google_Service_Indexing_UrlNotification();
$postBody->setType('URL_UPDATED');
$postBody->setUrl('https://example.com/jobs/' . $jobs[$i]['job_id']);
$batch ->add($service->urlNotifications->publish($postBody));
// ---- add request
$results = $batch->execute(); // it does authorize in execute() |
Seems like @millyhung posted a solution to the original problem. Thanks @millyhung ! |
I also have the same problem. I followed all the documentation provided by google. But I do not get the desired result. I would like to get clearer information about this code @millyhung |
I can't find the sample codes or documentations I saw. They may have been redirected to Github. The original problem |
I encountered the same problem, when I followed the solution provided by @millyhung , the problem was solved! |
Based on the Indexing API documentation: Using the Indexing API sending a batch request to the Indexing API, should use the following endpoint:
https://indexing.googleapis.com/batch
However, accessing this url will show this error:
404. That’s an error.
The requested URL /batch was not found on this server.
I followed this documentation(https://developers.google.com/api-client-library/php/guide/batch)
and here is my code:
and here is the running result:
//======================= result =====================//
//====================== The End of result ==============//
Then I dive into this documentation (https://developers.googleblog.com/2018/03/discontinuing-support-for-json-rpc-and.html).
Instead of using Google_Http_Batch Class which comes from Google API Client Libraries, I use GuzzleHttp\Pool Class, and GuzzleHttp\Psr7\Request Class, and I changed the endpoint from www.googleapis.com/batch to www.googleapis.com/batch/indexing/v3.
I am currently forming homogeneous batch requests and here is my code:
and here is the running result:
// =================== result ======================//
// =================== The End of result ================= //
I am not sure which endpoint I can use in order to send batch indexing requests using PHP(homogeneous batch requests).
Thanks for any help!
The text was updated successfully, but these errors were encountered: