我正在关注 Google 索引API
我想用 Google_Service_Indexing 发送批处理请求。
在PHP中,请帮助我。怎么做。在 Google 文档中,这是 Google_Service_Books。我尝试使用 PHP,例如:
//set google client
$client = new Google_Client();
$client->setAuthConfig('my_key.json');
$client->addScope('https://www.googleapis.com/auth/indexing');
$client->setUseBatch(true);
//set batch
$batch = new Google_Http_Batch($client);
//set service
$service = new Google_Service_Indexing($client);
$postBody = new Google_Service_Indexing_UrlNotification();
$postBody->setType('URL_UPDATED');
$postBody->setUrl('https://my_job_detail');
$service->urlNotifications->publish($postBody);
$batch ->add($service);
$results = $batch->execute();
我陷入了错误:
传递给 Google_Http_Batch::add() 的参数 1 必须实现接口 Psr\Http\Message\RequestInterface,给出 Google_Service_Indexing_UrlNotification 的实例,在 /Applications/MAMP/htdocs/Jukukoushi/src/Controller/ToppagesController.php 中调用,第 340 行请求 URL: /