PHP-Code:
function pingBingSitemaps($url_xml)
{
$status = 0;
$fp = @fsockopen("www.bing.com", 80);
if(!$fp)
{
echo "$errstr ($errno)<br />\n";
}
else
{
$req = 'GET /webmaster/ping.aspx?siteMap=' .
urlencode( $url_xml ) . " HTTP/1.1\r\n" .
"Host: www.bing.com\r\n" .
"User-Agent: Mozilla/5.0 (compatible; " .
PHP_OS . ") PHP/" . PHP_VERSION . "\r\n" .
"Connection: Close\r\n\r\n";
fwrite($fp, $req);
while(!feof($fp))
{
if(@preg_match('~^HTTP/\d\.\d (\d+)~i', fgets($fp, 128), $m))
{
$status = intval($m[1]);
break;
}
}
while (!feof($fp))
{
$res .= fgets($fp, 4096);
}
$res = explode("\r\n\r\n",$res,2);
$res = end($res);
echo $res;
fclose($fp);
}
return($status);
}
Kommentar