package NILab::WeblogUpdate; =head1 NAME NILab::WeblogUpdate - weblogUpdate.ping =head1 SYNOPSIS use NILab::WeblogUpdate; my @ping_server = ( 'http://rpc.weblogs.com/RPC2', 'http://ping.blo.gs/', 'http://ping.bloggers.jp/rpc/', ); $obj = NILab::WeblogUpdate->new(\@ping_server); # for debug $obj->{debug} = 1; # weblogUpdate.ping $obj->ping('name', 'http://localhost/'); =head1 AUTHOR NI-Lab. http://www.nilab.info/ =head1 LICENSE Copyright (c) 2005 NI-Lab. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 HISTORY Since: 2005-05-13 2005-06-06 * trapping error by eval at subroutine ping 2005-05-13 * add subroutine ping =cut #============================================================================== use strict; use warnings; use Frontier::Client; #============================================================================== # constructor #============================================================================== sub new { my $class = shift; my $self = { # initializeing field value ref_ping_server => shift, debug => 0, log => '', }; # my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ }; for hash params? bless $self,$class; return $self; } #============================================================================== # ping #============================================================================== sub ping{ my $self = shift; my $weblog_name = shift; my $weblog_url = shift; my $ref_ping_server = $self->{ref_ping_server}; my @ping_server = @{$ref_ping_server}; my $debug = $self->{debug}; my $log; foreach (@ping_server) { eval{ print STDERR "Pinging to $_ ...\n" if $debug; $log = $log . "Pinging to $_ ...\n"; my $server = Frontier::Client->new( url => $_, debug => $debug); my $result = $server->call('weblogUpdates.ping', $weblog_name, $weblog_url); for my $key (keys %$result) { print STDERR $key . ": " . $result->{$key} . "\n" if $debug; $log = $log . $key . ": " . $result->{$key} . "\n"; } print STDERR "Finished pinging to $_ ...\n" if $debug; $log = $log . "Finished pinging to $_ ...\n"; }; if($@){ print STDERR "$@\n" if $debug; $log = $log . "$@\n"; $@ = ''; } } $self->{log} = $log; return 1; } #============================================================================== 1;