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));
}
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.
After couple days of headache, here is the answer. Open your Google search console.
Prerequisite: You must already have a google service account
click the tri dot button, and click manage property owners:
add google service account email as new owners:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With