November 24, 2008

Below is a simple Perl script for sending XML-RPC pings to weblogs.com, Technorati, Google Blog Search, and similar sites. You can put this script somewhere in your $PATH, say ~/bin, and simply run xml-ping to notify the services listed in %urls of the changes. Of course, you should modify $site_name, $site_url, and %urls to your liking.

use strict;
use warnings;
require LWP::UserAgent;

my $site_name = 'SITE NAME';
my $site_url  = 'http://YOUR.URL/';

my %urls = (
    'Technorati'     => 'http://rpc.technorati.com/rpc/ping',
    'Google'         => 'http://blogsearch.google.com/ping/RPC2',
    'weblogs.com'    => 'http://rpc.weblogs.com/RPC2',
    'Moreover'       => 'http://api.moreover.com/RPC2',
    'NewsGator'      => 'http://services.newsgator.com/ngws/xmlrpcping.aspx',
    'Ping-o-Matic!'  => 'http://rpc.pingomatic.com/',

my $content = <<EOF;
<?xml version="1.0"?>

foreach my $site (keys %urls) {
    print "Pinging $site...";

    my $req = HTTP::Request->new('POST', $urls{$site});

    my $ua = LWP::UserAgent->new;