I would be really happy to get a solution for this. This is the error:
{ "error": { "code": 403, "message": "Permission denied. Failed to verify the URL ownership.", "status": "PERMISSION_DENIED" } }
As I have followed all the steps given in the google documentation.
I have verified the url ownership and added service account as owner. Here is the code snippet. Please check and reply with a solution, if you have.
include_once dirname(__FILE__)."/google-api-php-client_1/vendor/autoload.php";
$client = new Google_Client();
$client->setAuthConfig(dirname(__FILE__).'/xxxxxxxxxxxxxxxxxxxxx.json');
$client->addScope('https://www.googleapis.com/auth/indexing');
$httpClient = $client->authorize();
$endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish';
$array= array("url"=>"https://www.mycoders.in/career","type"=>"URL_UPDATED");
$content= json_encode($array);
$response = $httpClient->post($endpoint, [ 'body' => $content ]);
$response2 = $response->getBody()->getContents();
Thanks in advance! Rohit
Probably your service account is set to "Full" instead of Owner. If that is the case, you have to change your account to Owner. Use the Old Webmasters tool to do that.
https://support.google.com/webmasters/thread/4763732?hl=en