我正在调用 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));
}
调用 API 时,给出的响应是 '403 - Forbidden' 。
任何想法这个错误实际上意味着什么?我已经正确创建了服务帐户,但无法从我的开发环境中复制成功。