Perl Posting to Blogger blues
Table of Contents
Perl Posting to Blogger blues #
Happens that lately I’ve been working a bit with Blogger and trying to add support for this blog to Twitter-Daily. This task, I guess, is one of the exams to enter into some of Dante’s Inferno rings. Or at least it should.
To begin with just started reading Blogger APIs and my first bad feeling was that there’s no official Perl API library, then a quick search into CPAN throw me 3 implementations : WebService::Blogger, Net::Blogger and WWW::Blogger::XML::API.
WebService::Blogger
Just forget about it, it’s impossible to use even the provided sample that throws an awful error (see filed bug report)
Attribute (login_id) is required at constructor WebService::Blogger::new
WWW:Blogger:XML::API
I didn’t try it because it’s interface is too much bare bones for me.
Net::Blogger
The first two ones were just the blues intro, even that this has an OO interface is a bit outdated (but finally it worked!).
To begin with the API, and sample, contains an appkey that is useless these days (see bug report). Partly thanks to Ovid entry in Perlmonks you realize that the appkey is obsolete (deprecated ?).
Now the blog id thing. Thanks to Google help you can find it quickly.
Also happens that the script takes a while to run and ends with the next message : Net::Blogger::Engine::Blogger=HASH(0xa135410)
Thanks to a response to the previous message in Perlmonks can trace SOAP::Lite calls (use SOAP::Lite trace => ‘debug’;) and detected a timeout while connecting to plant.blogger.com. Also the new proxy is set in the same post : https://www.blogger.com/api/RPC2
Just to add insult to injury the https protocol is redirected to http, that was also catched by the SOAP::Lite trace (See the filed report bug)
Finally a simple sample can be used to test your Net::Logger install
use Net::Blogger;
print “############# Settings \n”;
my $b = Net::Blogger->new();
$b->BlogId(‘your_blog_id’);
$b->Username(‘your_username@gmail.com’);
$b->Password(‘your_password’);
$b->Proxy(‘http://www.blogger.com/api/RPC2');
print “############# Get recent posts \n”;
my ($ok,@p) = $b->getRecentPosts(numposts=>2);
if (! $ok) {
print “ERROR : “ . $b->LastError() . “\n”;
foreach my $key ( keys %{$b->LastError()} ) {
print “$key -> “ . $b->LastError()->{$key}
}
exit;
}
foreach my $post (@p) {
print “ — — — — — — — — — — — — — — — — — — — — — — — — — — — \n”;
foreach my $key ( keys %{$post} ) {
print “$key -> “ . $post->{$key} . “\n”;
}
}
print “######################## Publishing \n”;
my $result = $b->newPost({
postbody => ´This is text’,
publish => 1,
}) || croak $b->LastError();