Photoshop

Programming

Web Tech

Windows

XML Tutorial

Home » PHP, PHP Tutorial, Personal Tech, Programming, Scripts, Technology, Web Design, Web Pro Business, Web Tech, XML Tutorial

Ping your blog via XML-RPC with Perl

Submitted by admin on Thursday, 15 May 2008One Comment

The following Perl program connects to several update services to let them know that the your site or blog has been updated. The program uses XML-RPC to call the remote weblogUpdates.ping method of each update service with the name and URL of your site or blog as parameters. You can easily extend the list of update services that are used by the program if required so.


#!/usr/bin/perl
#
# rpcping.pl - Ping your blog with update services
#
# © Copyright, 2006 by John Bokma, http://johnbokma.com/
# License: The Artistic License
#
# Last updated: 2006-12-13 21:12:16 -0600

use strict;
use warnings;

use XMLRPC::Lite;

sub print_usage_and_exit {

print <
usage: rpcping.pl “YOUR WEBLOG NAME” URL
USAGE

exit;
}

@ARGV == 2 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 @services, 0, 2 ) {

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 ) {

chomp( my $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”;
}

Examples of program usage and output:

rpcping.pl "A Perl programmer in Mexico" http://johnbokma.com/mexit/
Ping 'Weblogs.com' returned: 'Thanks for the ping.'
Ping 'Feed Burner' returned: 'Ok'
Ping 'Feedster' returned: 'Thanks for the ping.'
Ping 'Blo.gs' returned the following error: 'Weblog already updated recently.'
Ping 'Syndic8' returned: 'Thanks for pinging Syndic8'
Ping 'BlogRolling' failed: 'Minimum time between pings not reached. Go have a
martini and try again in a bit.'
Ping 'Technorati' returned: 'Thanks for the ping'
Ping 'PubSub.com' returned: 'Ping Received.'

One Comment »

  • Mike Golvach said:

    Hey there,

    Great script and great idea to develop a perl app! I can’t wait to run it through its paces. Hats off to you :)

    , Mike

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.