2014-10-16, 03:11:42
OK, I did this:
Google had a slightly different URL, Bing was fine (I tried them manually, they said thank you) and ask.com doesn't offer this function anymore since 2014.
And now I get a wonderful message "4 search engines pinged", which is ridiculous now, but it is green :-)
Thank you!
PHP Code:
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 );
Google had a slightly different URL, Bing was fine (I tried them manually, they said thank you) and ask.com doesn't offer this function anymore since 2014.
And now I get a wonderful message "4 search engines pinged", which is ridiculous now, but it is green :-)
Thank you!