I am trying to check if my website page have been indexed by google. For this reason I am using Indexing API. For this reason I intent to call urlNotifications/metadata (documentation) to recieve metadata.
I am using php Google_api library for PHP. To set everything up I am using this docs to authorize and connect library. I created Application -> enable Index API -> created service account-> added permission from website to service account -> created APP credentials(json file). And used this cridentials to authorize client.
require_once GOOGLE_API_PATH;
$client = new Google_Client();
$client->setAuthConfig(GOOGLE_API_CREDENTIALS);
$client->addScope('https://www.googleapis.com/auth/indexing');
$httpClient = $client->authorize();
$json = array();
$json['test'] = 'test';
$json['credits'] = GOOGLE_API_CREDENTIALS;
$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications/metadata';
$response = $httpClient->get($endpoint,[
'query'=>['url' => 'https://bulbul.ua']
]);
//output debug data
$json['url'] = $endpoint;
$status_code = $response->getStatusCode();
$json['resp'] = $response->getStatusCode();
$json['msg'] = $response->getReasonPhrase();
$json['message'] = $response->getBody();
$this->response->setOutput(json_encode($json));
And the output is
{"test":"test","credits":"hidden:)","url":"https://indexing.googleapis.com/v3/urlNotifications/metadata","resp":404,"msg":"Not Found","message":{}}
Looks like I am recieving 404 error. heres a docs regarding this 404 error.
I know for sure that my website is indexed, especially this page.
Can someone help me with this issue?
I'm lost like Little Red Riding Hood In the forest of GoogleApi Settings.
You need to set the read permission of gsc