odyniec.net

Archive for the ‘Perl’ Category

WebService::Gravatar — Perl interface to Gravatar XML-RPC API

Tuesday, August 3rd, 2010

Developing my first Perl module turned out to be quite amusing, so I was happy to do it again, and here’s my second contribution to the wonderful world of CPAN: WebService::Gravatar, a Perl interface to Gravatar XML-RPC API.

Here’s a quick usage example (taken from the documentation):

use WebService::Gravatar; use MIME::Base64; # Create a new instance of WebService::Gravatar my $grav = WebService::Gravatar->new(email => 'your@email.address', apikey => 'your_API_key'); # Get a list of addresses my $addresses = $grav->addresses; if (defined $addresses) { # Print the userimage URL for each e-mail address foreach my $email (keys %$addresses) { print $addresses->{$email}->{'userimage_url'} . "\n"; } } else { # We have a problem print STDERR "Error: " . $grav->errstr . "\n"; } # Read image file data my $data; { local $/ = undef; open(F, "< my_pretty_face.png"); $data = <F>; close(F); } # Save the image as a new userimage $grav->save_data(data => encode_base64($data), rating => 0); ...

WebService::EditDNS – Perl interface to EditDNS API

Monday, July 26th, 2010

I have created a simple Perl module that talks to EditDNS API, allowing for easy manipulation of domains/records hosted at EditDNS from within Perl programs. A while ago, I developed a command-line utility that serves a similar purpose, named editdns.pl. The module is sort of an extension of that idea, although it works in a different manner — while editdns.pl impersonates a web browser to access the EditDNS control center website and uses hacky HTML scraping techniques, the module plays it nice and only uses elegant API calls.

The module is called WebService::EditDNS, and is available for download at CPAN. Eventually, it will probably also get a project homepage here on my website (some day in the not-too-distant future).