Ошибка 403 в API индексации Google - PullRequest
0 голосов
/ 15 мая 2019

Я хочу выполнить код "API индексации Google".

<?php
require_once 'google-api-php-client-2.2.2/vendor/autoload.php';

$client = new Google_Client();


// service_account_file.json is the private key that you created for your service account.
$client->setAuthConfig('service_account_file.json');
$client->addScope('https://www.googleapis.com/auth/indexing');

// Get a Guzzle HTTP Client
$httpClient = $client->authorize();
$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';

// Define contents here. The structure of the content is described in the next step.
$content = '{
  \"url\": \""http://example.com/jobs/42.html\",
  \"type\": \"URL_UPDATED"
}';

$response = $httpClient->post($endpoint, [ 'body' => $content ]);
$status_code = $response->getStatusCode();

echo $status_code;
?>

Но в ответ я получаю сообщение об ошибке: 403.

Я создал учетную запись службы и Проверка сайтазавершено

Я хочу добавить адрес электронной почты учетной записи службы в консоли поиска Google.

В чем проблема в нашем коде?

Цените любую помощь и идеи.Спасибо!

...