1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[GET] Perl xmlrpc ping script

Discussion in 'Blogging' started by cooooookies, Jan 11, 2009.

Tags:
  1. cooooookies

    cooooookies Senior Member

    Joined:
    Oct 6, 2008
    Messages:
    1,008
    Likes Received:
    216
    Wordpress (MU) ping is so annyoing, so I searched a little...

    Here is a nice and WORKING perl xmlrpc ping script, easy to put it into a cronjob or to use it with many sites.

    The XMLRPC::Lite package is btw included in SOAP::Lite.

    PHP:
    #!/usr/bin/perl
    #
    # rpcping.pl - Ping your blog with update services
    #
    # © Copyright, 2006 by John Bokma, http://johnbokma.com/
    # License: The Artistic License
    #
    # $Id: rpcping.pl 1083 2008-09-30 19:06:18Z john $ 

    use strict;
    use 
    warnings;

    use 
    XMLRPC::Lite;

    sub print_usage_and_exit {

        print <<
    USAGE;
    usagerpcping.pl "YOUR WEBLOG NAME" URL
    USAGE

        
    exit;
    }

    @
    ARGV == or print_usage_and_exit;
    my $blog_name$blog_url ) = @ARGV;

    my @services = (

        
    # See http://codex.wordpress.org/Update_Services for
        # a more comprehensive list.
        
    'Google'         => 'http://blogsearch.google.com/ping/RPC2',
        
    'Weblogs.com'    => 'http://rpc.weblogs.com/RPC2',
        
    'Feed Burner'    => 'http://ping.feedburner.com/',
        
    'Moreover'       => 'http://api.moreover.com/RPC2',
        
    'Syndic8'        => 'http://ping.syndic8.com/xmlrpc.php' ,
        
    'BlogRolling'    => 'http://rpc.blogrolling.com/pinger/',
        
    'Technorati'     => 'http://rpc.technorati.com/rpc/ping' ,
        
    'BulkFeeds'      => 'http://bulkfeeds.net/rpc',
        
    'BlogFlux'       => 'http://pinger.blogflux.com/rpc/',
        
    'Ping-o-Matic!'  => 'http://rpc.pingomatic.com/',
        
    'NewsGator'      => 'http://services.newsgator.com/ngws/xmlrpcping.aspx',
        
    'Blog People'    => 'http://www.blogpeople.net/servlet/weblogUpdates',
        
    'Howly Cow Dude' => 'http://www.holycowdude.com/rpc/ping/',
        
    'Blog Update'    => 'http://blogupdate.org/ping/',
        
    'FeedSky'        => 'http://www.feedsky.com/api/RPC2',
    );

    while ( 
    my $service_name$rpc_endpoint ) = splice @services0) {

        
    my $xmlrpc XMLRPC::Lite->proxy$rpc_endpoint );
        
    my $call;
        eval {
            
    $call $xmlrpc->call'weblogUpdates.ping',
                
    $blog_name$blog_url );
        };
        if ( $@ ) {

            
    chomp $@;
            
    warn "Ping '$service_name' failed: '$@'\n";
            
    next;
        }

        
    unless defined $call ) {

            
    warn "Ping '$service_name' failed for an unknown reason\n";
            
    next;
        }

        if ( 
    $call->fault ) {

            
    chompmy $message $call->faultstring );
            
    warn "Ping '$service_name' failed: '$message'\n";
            
    next;
        }

        
    my $result $call->result;
        if ( 
    $result->{ flerror } ) {

            
    warn "Ping '$service_name' returned the following error: '",
                
    $result->{ message }, "'\n";
            
    next;
        }

        print 
    "Ping '$service_name' returned: '$result->{ message }'\n";
    }
     
    • Thanks Thanks x 2
  2. trecords

    trecords Registered Member

    Joined:
    Oct 5, 2008
    Messages:
    96
    Likes Received:
    87
    I use joomla bloging, can i use it?
    Thank you
     
  3. bwh48

    bwh48 BANNED BANNED

    Joined:
    Jun 30, 2007
    Messages:
    56
    Likes Received:
    54
    The things with WPMU is that all the ping functionality of WP is included, but they have decided to not allow us users to add any more ping servers..

    But a simple bit of PHP code can fix all this..

    Try the following:

    Step 1.
    Create a text file (must be called pinglist.txt) of all the ping servers you would like your wp blogs to ping
    something like :
    Code:
    http://1470.net/api/ping
    http://a2b.cc/setloc/bp.a2b
    http://api.feedster.com/ping
    http://api.moreover.com/RPC2
    http://api.my.yahoo.co.jp/RPC2
    http://api.my.yahoo.com/rss/ping
    http://audiorpc.weblogs.com/RPC2
    http://bitacoles.net/ping.php
    http://blog.goo.ne.jp/XMLRPC
    
    Step 2:

    using notepad, copy the following PHP code and save as wpmu-pinglist.php

    Code:
    <?php
    require_once(dirname(__FILE__).'/wp-config.php');
    $mysql_server			= DB_HOST;
    $mysql_username			= DB_USER;
    $mysql_password			= DB_PASSWORD;
    $mysql_database			= DB_NAME;
    
    $pinglist = file(dirname(__FILE__).'/pinglist.txt');
    $pingliststr=trim(implode("\n",$pinglist));
    
    // Connect to database
    $db = mysql_connect($mysql_server, $mysql_username,  $mysql_password);
    mysql_select_db($mysql_database, $db);
    
    $sql = "SELECT blog_id FROM wp_blogs order by blog_id asc;";
    $sql = mysql_query($sql) or die(mysql_error().'<br>Line : '.__LINE__.'<br>'.$sql);
    while( $row = mysql_fetch_assoc($sql) )
    {
      $blogid = $row['blog_id'];
      $q = "update wp_{$blog_id}_options set option_value='$pingliststr' where option_name='ping_sites';";
      mysql_query($q) or die(mysql_error().'<br>Line : '.__LINE__.'<br>'.$sql);
    }
    echo 'All Done!!!<br>';
    ?>
    
    Now FTP both files up into the root directory of your blog, and then
    using your web browser, simply go :

    Code:
    htttp://www.your-wpmu-blog-site.com/wpmu-pinglist.php
    
    And within seconds (assuming you copied and pasted everything OK), you will now have a "pile" of ping servers attached to every blog.

    If you add a new blog, then simply run the script again..

    Hope this helps