2015-03-12, 00:43:01
No, I did not... it gave me no error, but bing.com describes another way:
This is my code today: (Bing seems to be wrong)
Quote:Pinging Bing Using a HTTP request
If you have an automated system that generates your sitemap, you may find it easier to inform Bing about your sitemap by sending a HTTP request. Using your favorite method to send the request, use the following URL, replacing the example with your sitemap location and URL encoding everything behind the sitemap parameter:
http://www.bing.com/ping?sitemap=http%3A...itemap.xml
This is my code today: (Bing seems to be wrong)
PHP Code:
* Ping Sitemaps
*
* @since 1.0
*
* @param string $url_xml XML sitemap
* @return bool
*/
function pingGoogleSitemaps($url_xml) {
$status = 0;
$google = 'www.google.com';
$bing = 'www.bing.com';
$ask = 'submissions.ask.com';
if( $fp=@fsockopen($google, 80) ) {
$req = 'GET /webmasters/tools/ping?sitemap=' . /* old: 'GET /webmasters/sitemaps/ping?sitemap=' . */
urlencode( $url_xml ) . " HTTP/1.1\r\n" .
"Host: $google\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;
}
}
fclose( $fp );
}
if( $fp=@fsockopen($bing, 80) ) {
$req = 'GET /webmaster/ping.aspx?sitemap=' .
urlencode( $url_xml ) . " HTTP/1.1\r\n" .
"Host: $bing\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;
}
}
fclose( $fp );
}
/* invalid since 2014: no direct pings to ask.com
if( $fp=@fsockopen($ask, 80) ) {
$req = 'GET /ping?sitemap=' .
urlencode( $url_xml ) . " HTTP/1.1\r\n" .
"Host: $ask\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;
}
}
fclose( $fp );
}
*/
return( $status );
}