$sitemapUrl = 'http://www.monsite.com/sitemap.xml';
//google
$google_return = pingSitemap($sitemapUrl, 'http://www.google.com/webmasters/sitemaps/ping?sitemap=');
//ask
$ask_return = pingSitemap($sitemapUrl, 'http://submissions.ask.com/ping?sitemap=');
//yahoo
$yahoo_return = pingSitemap($sitemapUrl, 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=');
echo $google_return;
echo $ask_return;
echo $yahoo_return;
function pingSitemap ($sitemapUrl, $notifyUrl) {
$fileName = $notifyUrl . urlencode($sitemapUrl);
$url = parse_url($fileName);
if (!isset($url["port"])) $url["port"] = 80;
if (!isset($url["path"])) $url["path"] = "/";
$fp = @fsockopen($url["host"],
$url["port"],
&$errno, &$errstr, 30);
if ($fp) {
$head = "";
$httpRequest = "HEAD ". $url["path"] ."?"
.$url["query"] ." HTTP/1.1\r\n"
."Host: ". $url["host"] ."\r\n"
."Connection: close\r\n\r\n";
fputs($fp, $httpRequest);
while(!feof($fp)) $head .= fgets($fp, 1024);
fclose($fp);
return $head;
}
return "ERROR";
}