WordPress发布文章后主动ping搜索引擎

WordPress发布文章后主动ping搜索引擎

百度的ping服务

// 文章公布自动ping baidu,写入functions.php
function pingbaidu($post_id) {
    $baiduXML = 'weblogUpdates.extendedPing' . get_option('blogname') . ' ' . home_url() . ' ' . get_permalink($post_id) . ' ' . get_feed_link() . ' ';
    $wp_http_obj = new WP_Http();
    $return = $wp_http_obj->post('http://ping.baidu.com/ping/RPC2', array('body' => $baiduXML, 'headers' => array('Content-Type' => 'text/xml')));
    if(isset($return['body'])){
        if(strstr($return['body'], '0')){
            $noff_log='succeeded!';
        }
        else{
            $noff_log='failed!';
        }
    }else{
        $noff_log='failed!';
    }
}
add_action('publish_post', 'pingbaidu');

其他搜索引擎的ping服务

http://ping.baidu.com/ping/RPC2
http://rpc.pingomatic.com/
http://blogsearch.google.com/ping/RPC2
http://api.my.yahoo.com/RPC2
http://api.my.yahoo.com/rss/ping
http://ping.feedburner.com
http://www.zhuaxia.com/rpc/server.php
http://www.xianguo.com/xmlrpc/ping.php
http://www.feedsky.com/api/RPC2
http://blog.iask.com/RPC2
http://ping.blog.qikoo.com/rpc2.php
http://rpc.technorati.com/rpc/ping
http://www.blogsdominicanos.com/ping/