[Xml-compile] XML::Compile::RPC suitable for use with MailChimp API?

Mark Blackman m.blackman at fairfx.com
Tue May 24 16:55:01 GMT 2011


Hi,

I'm trying to use the MailChimp API via XML::Compile::RPC, but I'm finding the generated
result hashes far too verbose. In particular, the $response below is full of keys with
names like 'name' and 'value'. Surely, XML::RPC should just map these into a hash?

struct_to_hash almost seems right, but isn't recursive.  XML::RPC::Fast produces
the hashes I expect and I would have though XML::Compile::RPC would as well.

Any clues?

Regards,
Mark

### Initialization Section
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG);    # Set priority of root logger to DEBUG

use XML::Compile::RPC::Client;
use XML::Compile::RPC::Util qw/struct_to_hash struct_from_hash/;

my $rpc = XML::Compile::RPC::Client->new(destination => 'http://us1.api.mailchimp.com/1.3/');

my $apikey='**obscured**';

($rc, $response) = $rpc->call('lists', string => $apikey);
$rc == 0
  or die "error: $response\n";
$trace = $rpc->trace;            # facts about the last call

get_logger->debug(Dumper($trace));

get_logger->info("lists is ".Dumper($response));

my $hash = struct_to_hash $response;
get_logger->info("hash is ".Dumper($hash));





More information about the Xml-compile mailing list