我真的很乐意为此找到解决方案。这是错误:
{ "error": { "code": 403, "message": "Permission denied. 无法验证 URL 所有权。", "status": "PERMISSION_DENIED" } }
因为我已经按照谷歌文档中给出的所有步骤。
我已经验证了 url 所有权并将服务帐户添加为所有者。这是代码片段。如果有,请检查并回复解决方案。
include_once dirname(__FILE__)."/google-api-php-client_1/vendor/autoload.php";
$client = new Google_Client();
$client->setAuthConfig(dirname(__FILE__).'/xxxxxxxxxxxxxxxxxxxxx.json');
$client->addScope('https://www.googleapis.com/auth/indexing');
$httpClient = $client->authorize();
$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';
$array= array("url"=>"https://www.mycoders.in/career","type"=>"URL_UPDATED");
$content= json_encode($array);
$response = $httpClient->post($endpoint, [ 'body' => $content ]);
$response2 = $response->getBody()->getContents();
提前致谢!罗希特