Darryl Hein
Darryl Hein

Reputation: 144967

How do you notify Google through code that there is a updated sitemap?

On this page of Google help:

https://www.google.com/webmasters/tools/docs/en/sitemap-generator.html#submitting

Google mentions that there is a way to notify them of an updated sitemap using an HTTP request.

When you click the link, it takes you to this page:

http://www.google.com/support/webmasters/bin/answer.py?answer=34592&topic=8482&hl=en#ping

But there is no information on where to ping with what request.

Does anyone know what this address is and what parameters are required?

Upvotes: 16

Views: 3272

Answers (4)

Ankit Anand
Ankit Anand

Reputation: 171

Google has the complete procedure for how to notify them update site updates including how to ping using http request (the official google method) and also using their feed. Read the official document here https://webmasters.googleblog.com/2014/10/best-practices-for-xml-sitemaps-rssatom.html

Hope that helps :-)

Upvotes: 1

jaggedsoft
jaggedsoft

Reputation: 4038

Simplest solution: file_get_contents("https://www.google.com/webmasters/tools/ping?sitemap={$sitemap}");

That will work on every major hosting provider. If you want optional error reporting, here's a start:

$data = file_get_contents("https://www.google.com/webmasters/tools/ping?sitemap={$sitemap}");
$status = ( strpos($data,"Sitemap Notification Received") !== false ) ? "OK" : "ERROR";
echo "Submitting Google Sitemap: {$status}\n";

As for how often you should do it, as long as your site can handle the extra traffic from Google's bots without slowing down, you should do this every time a change has been made.

Upvotes: 2

chaos
chaos

Reputation: 124297

http://www.google.com/webmasters/sitemaps/ping?sitemap=URL-encoded URL to your sitemap

Upvotes: 20

Related Questions