#!/usr/bin/perl # # Description: Test script for fetching a list of TypeLists # Author: Byrne Reese # use XML::Atom::Client; use XML::Atom::Entry; sub get_typelists { my $lists; my $feed = $api->getFeed("http://www.typepad.com/t/atom/lists"); my @links = $feed->link(); foreach my $l (@links) { my ($id) = ($l->href =~ /list_id=(\d+)/); if ($l->rel eq 'service.feed') { $lists->{$id}->{'feed'} = $l->href; } elsif ($l->rel eq 'service.post') { $lists->{$id}->{'post'} = $l->href; } $lists->{$id}->{'title'} = $l->title; $lists->{$id}->{'type'} = $l->{elem}->getAttributeNS($ListNS,'type'); } return $lists; } sub prompt { my ($msg) = @_; print "$msg "; my $in = ; chomp $in; return $in; } my $ListNS = 'http://www.sixapart.com/atom/list#' my $api = XML::Atom::Client->new; $api->username(prompt("Enter your TypePad username:")); $api->password(prompt("Enter your TypePad password:")); my $lists = get_typelists(); foreach my $id (keys %$lists) { $list = $lists->{$id}; print "TypeList #".$id."\n"; foreach my $key (keys %$list) { print " $key = ".$list->{$key}."\n"; } }