小编Joe*_*son的帖子

Google Indexing API-403“禁止响应”

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

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));
}
Run Code Online (Sandbox Code Playgroud)

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

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

php google-api symfony google-api-php-client google-indexing-api

5
推荐指数
4
解决办法
2182
查看次数