Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A error message generating the SiteMap
#35
OK, I tried this PHP code, but I cannot control it, since I cannot do this:
Quote: do valid response checking, or combine the statuses into a result.

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($google80) ) {
      
$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($fp128), $m) ) {
            
$status intval$m[1] );
            break;
         }
      }
      
fclose$fp );
   }
   
   if( 
$fp=@fsockopen($bing80) ) {
      
$req =  'GET /ping?sitemap=' /* old: '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($fp128), $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 );

Reply


Messages In This Thread
A error message generating the SiteMap - by D.O. - 2013-09-13, 05:25:43
RE: A error message generating the SiteMap - by Hypertexter - 2015-03-12, 00:56:35



Users browsing this thread: 1 Guest(s)