How to ping search engines when sitemap is updated using php

Post Reply
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

How to ping search engines when sitemap is updated using php

Post by Neo » Sun Apr 04, 2010 4:33 pm

Informing search engines that your site content has been updated is an important task. Google downloads your site-map automatically every few days, or even few hours If you are running a big website. However, Webmasters like to ping Search Engines automatically after every update on the website. Here are few links for several search engines that you may want to ping.
  • Google

    Code: Select all

    http://www.google.com/webmasters/tools/ping?sitemap=http://site.com/sitemap.xml
  • Yahoo

    Code: Select all

    http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=http://site.com/sitemap.xml
  • Bing

    Code: Select all

    http://www.bing.com/webmaster/ping.aspx?siteMap=http://site.com/sitemap.xml
  • Ask

    Code: Select all

    http://submissions.ask.com/ping?sitemap=http://site.com/sitemap.xml
Here is how you can do it with php.

Code: Select all

<?php

function pingMySitemap($url){
    @file_get_contents("http://www.google.com/webmasters/tools/ping?sitemap=" . urlencode$url));
    @file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=" . urlencode($url));
    @file_get_contents("http://www.bing.com/webmaster/ping.aspx?siteMap=" . urlencode($url));
    @file_get_contents("http://submissions.ask.com/ping?sitemap=" . urlencode($url));
}

// using the function..
pingMySitemap("https://robot.lk/sitemap.php");

?>
Post Reply

Return to “PHP & MySQL”