bayadır bir şey eklemiyordum, wordpress 2.5 güncellemesini de yaptıktan sonra artık bir şeyler yazasım geldi
bu kodu ben yazmadım, fakat işlerinizde çok işinize yarayacağına eminim. google a sitemap.xml lerin güncellenmesi için ping atıp bir nevi “gel beni indexle” diyor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | <?php /** * Function to ping Google Sitemaps. * * Function to ping Google Sitemaps. Returns an integer, e.g. 200 or 404, * 0 on error. * * @author J de Silva <giddomains@gmail.com> * @copyright Copyright © 2005, J de Silva * @link http://www.gidnetwork.com/b-54.html PHP function to ping Google Sitemaps * @param string $url_xml The sitemap url, e.g. http://www.example.com/google-sitemap-index.xml * @return integer Status code, e.g. 200|404|302 or 0 on error ... A successful request will return an HTTP 200 response code; if you receive a different response, you should resubmit your request... */ function pingGoogleSitemaps( $url_xml ) { $status = 0; $google = 'www.google.com'; if( $fp=@fsockopen($google, 80) ) { $req = '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 ); } return( $status ); } // Once the sitemaps are ready, we ping Google... if( 200 === ($status=pingGoogleSitemaps('http://www.siteniz.com/sitemap-adresiniz.xml')) ) echo "pingleme tamam"; else echo "error: pingleme tamam değil"; // end the script. ?> |
afiyet olsun
0 Responses to “PHP Google Sitemap Pingleme”
Leave a Reply