Click to See Complete Forum and Search --> : Pinging Google


edatz
09-28-2009, 03:56 PM
Hi, I've had a blowout on an old script to ping a search engine for my page and am wondering if this one is right.

Has anyone experience with these things?
I did check Google's page about this and the xml appears to be in line with what they say there.
I know that using a pinging service can take ages, which is why I'm just pinging Google direct.


#!/usr/bin/perl

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

my $site_name = 'Site Name';
my $site_url = 'http://www.msite.com/';
my $site_rss = 'myblog.xml';

my %urls = (
'Google' => 'http://blogsearch.google.com/ping/RPC2',
);

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>
<param><value>$site_rss</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;
}


Any help would be appreciated,
many thanks

edatz
10-28-2009, 01:18 PM
Turns out this is okay, but it doesn't tell me when it has finished like my old one did.