1

I've used Wordpress's plugin that notifies a few search engines every time you make a new post. However i'm thinking of developing a website that users submit stuff to, how can i use PHP to notify Google with an XML sitemap (or similar method) of the site changes as and when they happen, so users submissions are searchable/indexed quickly by Google.

benhowdle89
  • 36,900
  • 69
  • 202
  • 331

4 Answers4

6

To ping Google, the ping url is:

http://www.google.com/webmasters/sitemaps/ping?sitemap=http://www.yoursite.com/sitemap-file.xml

captainblack
  • 4,107
  • 5
  • 50
  • 60
Poelinca Dorin
  • 9,577
  • 2
  • 39
  • 43
0

For PHP:

file_get_contents("https://www.google.com/webmasters/sitemaps/ping?sitemap=https://domain.tld/sitemap.xml")

For Python:

import requests
requests.get("https://www.google.com/webmasters/sitemaps/ping?sitemap=https://domain.tld/sitemap.xml")
Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268
-1
shell_exec('ping -c1 www.google.com/webmasters/sitemaps/ping?sitemap=http://www.website.com/sitemap.php');
-1

Issue your request to the following URL: www.google.com/webmasters/tools/ping?sitemap=sitemap_url Issue the HTTP request using wget, curl, or another mechanism of your choosing. A successful request will return an HTTP 200 response code, if you receive a different response, you should resubmit your request.

Artless
  • 4,522
  • 1
  • 25
  • 40
K. V. Suresh
  • 897
  • 7
  • 8