Skip to content

Instantly share code, notes, and snippets.

@shelling
Created August 24, 2009 03:26
Show Gist options
  • Save shelling/173636 to your computer and use it in GitHub Desktop.
Save shelling/173636 to your computer and use it in GitHub Desktop.
#!/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