|
||||
|
« Conversion: Binary, Decimal, Hexadecimal | Command Line Arguments, Part 1 » |
PHP function to ping Google Sitemaps
by: admin - Aug 29, 2005
Now that I have completed writing the custom PHP script that generates the Google sitemaps for GIDForums, I thought it would be helpful to share with you some of the functions that were included in the script. One of the most useful, I think, is the pingGoogleSitemaps() function below. All it does is ping Google Sitemaps to let them know that your sitemap (or sitemap index) file has recently been updated. Just in case you need more information about submitting your sitemaps, you can read about it here: Submitting your Google Sitemaps. Custom PHP function: pingGoogleSitemaps()PHP Code Example:
I just want to point out this sentence from the Submitting your Google Sitemaps page:
Which is why this function simply returns the 3 digit HTTP status code at the end and nothing more. If for some strange reason, it fails to even connect to www.google.com however, it will just return 0. Example use: pingGoogleSitemaps()For GIDForums™, I set up a cron job to run daily, generating up to 3 (Google) sitemaps and 1 sitemap index file. Let's assume the 3 sitemaps are:
When the cron job executes cron-sitemap-generator.php everyday, the script queries the database and generates the sitemap files accordingly. As soon as it's done writing to these files, it uses the same information to produce the sitemap INDEX file, filenamed: sitemap-index.xml. This INDEX file is what we need to ping to Google Sitemaps and we use this pingGoogleSitemaps() function to do that easily -- see the following example code: PHP Code Example:
My personal experience with automated pings to Google Sitemaps is that it takes anywhere between 1 - 23 hours for Googlebot to come around and fetch the updated sitemaps and index file.
|
GIDNetwork Sites
Archives
Recent GIDBlog Posts
Recent GIDForums Posts
Contact Us
|
« Conversion: Binary, Decimal, Hexadecimal | Command Line Arguments, Part 1 » |