1
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
import json


# https://developers.google.com/search/apis/indexing-api/v3/prereqs#header_2
JSON_KEY_FILE = "key.json"
SCOPES = ["https://www.googleapis.com/auth/indexing"]


def indexURL(urls):
    credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE,   scopes=SCOPES)
    http = credentials.authorize(httplib2.Http())
    ENDPOINT = "https://indexing.googleapis.com/v3/urlNotifications:publish"
    
    for u in urls:
    
        content = {}
        content['url'] = u.strip()
        content['type'] = "URL_UPDATED"
        json_ctn = json.dumps(content)
        response, content = http.request(ENDPOINT, method="POST", body=json_ctn)
        result = json.loads(content.decode())
        print(result)
        try:
          if result['error']:
            return False
          else:
            return True
        except:
          return True

is the code I found in a gist. It seems to work and gives good responses and all, but when I search for my website, NOTHING SHOWS UP! I am so distraught. I am saddened. Frustrated as well. I don't want to give up.

1 Answers1

0

You can check google notification status

colynn liu
  • 61
  • 3