-2

I have been tyring to get this api working for literally hours. I can't even get the try this api part working with api key. I tried to use it with cURL like this:

$submitSite = curl_init($submit_url);

curl_setopt_array($submitSite, [CURLOPT_PUT => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Accept: application/json"]]);
$responseContent = curl_exec($submitSite);

But it returns 0. I url encoded siteUrl and feedpath parts and added the api key at the end. How can I submit my website's sitemap automatically?

Rookie
  • 175
  • 1
  • 4
  • 19
  • have a look at how to properly debug curl https://stackoverflow.com/questions/3757071/php-debugging-curl –  Aug 11 '19 at 22:02

1 Answers1

-1

You're missing the authorization part. You must have the proper permissions to https://www.googleapis.com/auth/webmasters to add the sitemap.

In your code I don't see any headers for this authorization. For more info check: https://developers.google.com/webmaster-tools/search-console-api-original/v3/how-tos/authorizing

Paul
  • 329
  • 1
  • 8