Automatic Cronjob for Sitemap submission

Discussion in 'PHP' started by NLZ13, Mar 5, 2011.

  1. #1
    Made this recently and I figured this might be easy for some of you. Just upload the script to your server only edit the sitemap url and attach it to a cronjob that works like 1 time every day. It submits to google, bing, yahoo and ask.

    <?php
    	$sm_url = "http://mydomainname.extension/sitemap.xml";
    	
    	$se_list = array("http://www.google.com/webmasters/sitemaps/ping?sitemap=",
    					 "http://www.bing.com/webmaster/ping.aspx?siteMap=",
    					 "http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=",
    					 "http://submissions.ask.com/ping?sitemap=");
    
    		
    	foreach($se_list as $i){
    		$url_to_ping = $i . $sm_url;
    
    		if ($i == "http://www.google.com/webmasters/sitemaps/ping?sitemap=") {
    			$host = "Google";
    		} elseif ($i == "http://www.bing.com/webmaster/ping.aspx?siteMap=") {
    			$host = "Bing";
    		} elseif ($i == "http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=") {
    			$host = "Yahoo";
    		} else {
    			$host = "Ask";
    		}	
    
    		$data = file_get_contents($url_to_ping);
    
    		if ($data) {
    		          // do something if succeeded
    		} else {
    		          // do something if failed, like mail yourself of a submit failure to specific $host
    		}
    
    	}	
    ?>
    PHP:
     
    NLZ13, Mar 5, 2011 IP
  2. ACME Squares

    ACME Squares Peon

    Messages:
    98
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Or just add the sitemap to robots.txt?
     
    ACME Squares, Mar 5, 2011 IP
  3. NLZ13

    NLZ13 Well-Known Member

    Messages:
    166
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    113
    #3
    guess not every website is crawled every day?
     
    NLZ13, Mar 5, 2011 IP
  4. ACME Squares

    ACME Squares Peon

    Messages:
    98
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The search engines cache the sitemap address practically forever.
    Pinging every day is completely pointless.
     
    ACME Squares, Mar 5, 2011 IP