Created
August 24, 2009 03:26
-
-
Save shelling/173636 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use LWP::UserAgent; | |
use HTTP::Request; | |
use UNIVERSAL::dump; | |
use YAML qw(LoadFile); | |
package HTTP::Request; | |
sub authorization_basic { | |
my ($self, $user, $pass) = @_; | |
$self->SUPER::authorization_basic($user, $pass); | |
return $self; | |
} | |
sub submit_by { | |
my ($self, $ua) = @_; | |
$ua->request($self); | |
} | |
package HTTP::Response; | |
use XML::Simple; | |
sub xmlized_content { | |
my ($self) = @_; | |
$content = $self->content; | |
$content =~ s/name/title/g; | |
XMLin($content); | |
} | |
package main; | |
use Data::Dumper; | |
my $config = LoadFile("$ENV{HOME}/.posterous")->{core}; | |
$UA = LWP::UserAgent->new; | |
print Dumper( | |
HTTP::Request | |
->new(GET => "http://posterous.com/api/getsites") | |
->authorization_basic($config->{user}, $config->{pass}) | |
->submit_by($UA) | |
->xmlized_content | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment