xml-ping
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.
#!/usr/bin/perl
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"?>
<methodCall>
<methodName>weblogUpdates.ping</methodName>
<params>
<param><value>$site_name</value></param>
<param><value>$site_url</value></param>
</params>
</methodCall>
EOF
foreach my $site (keys %urls) {
print "Pinging $site...";
my $req = HTTP::Request->new('POST', $urls{$site});
$req->content_type('text/xml');
$req->content($content);
my $ua = LWP::UserAgent->new;
$ua->request($req)->as_string;
}