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

4

16

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?

Parcel answered 11/2, 2009 at 21:15 Comment(0)
T
20

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

Toms answered 11/2, 2009 at 21:21 Comment(0)
S
2

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.

Spiccato answered 18/11, 2015 at 2:11 Comment(0)
S
1

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 :-)

Sadden answered 19/4, 2016 at 6:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.