相关疑难解决方法(0)

索引 API 403 权限被拒绝。无法验证 URL 所有权

我想执行示例中的代码:

    require_once 'google-api-php-client/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\", //I used real url from my homepage
      \"type\": \"URL_UPDATED\"
    }";

    $response = $httpClient->post($endpoint, [ 'body' => $content ]);
    $status_code = $response->getStatusCode();
Run Code Online (Sandbox Code Playgroud)

但作为回应,我收到一个错误:403“权限被拒绝。无法验证 URL 所有权。”。

  1. 我创建了服务帐户并在我的应用程序中读取了该文件。
  2. 网站已验证。 …

indexing google-api google-indexing-api

6
推荐指数
2
解决办法
1169
查看次数

标签 统计

google-api ×1

google-indexing-api ×1

indexing ×1