Google Indexing API-403“禁止响应" [英] Google Indexing API - 403 'Forbidden Response'

查看:239
本文介绍了Google Indexing API-403“禁止响应"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在致电google indexing API进行职位发布:

I am making a call to the google indexing API for job postings:

private $client;
private $httpClient;

public function initClient($kernel)
{
    $this->client = new \Google_Client();
    $this->client->setAuthConfig(JSON_KEY_HERE);
    $this->client->addScope('https://www.googleapis.com/auth/indexing');
    $this->httpClient = $this->client->authorize();
}

public function sendJob()
{
    $endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';
    $content = "{
                    \"url\": \"URL_HERE\",
                    \"type\": \"URL_UPDATED\"
                }";

    $response = $this->httpClient->post($endpoint, array('body' => $content));
}

调用API时,给出的响应为"403-Forbidden"

When making the call to the API, the response given is '403 - Forbidden' .

有什么主意,这个错误实际上意味着什么?我已经正确创建了服务帐户,但是无法从开发环境中复制成功.

Any ideas what this error actually means? I have created the service account correctly but cannot replicate success from my dev enviroment.

推荐答案

请确保您已按照以下说明在Google Search Console中将服务帐户添加为所有者: com/search/apis/indexing-api/v3/prereqs#verify-site"rel =" nofollow noreferrer> https://developers.google.com/search/apis/indexing-api/v3/prereqs#verify-site .

Make sure that you have added the service account as an Owner in Google Search Console as described here: https://developers.google.com/search/apis/indexing-api/v3/prereqs#verify-site.

我的问题是我们在Search Console中有多个域条目(带有和不带有www以及带有和不带有https);将服务帐户作为所有者添加到所有4个条目之后,它就可以正常工作.

My problem was that we had multiple entries for the domain in the Search Console (with and without www and with and without https); after adding the service account as an owner to all 4 entries it's working.

这篇关于Google Indexing API-403“禁止响应"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆