Skip to content

Instantly share code, notes, and snippets.

@shelling
Created August 23, 2009 14:58
Show Gist options
  • Select an option

  • Save shelling/173326 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/173326 to your computer and use it in GitHub Desktop.
using LWP with HTTP Basic Authentication
#!/usr/bin/env perl
use LWP::UserAgent;
use HTTP::Request;
use UNIVERSAL::dump;
use XML::Simple;
use Data::Dumper;
use YAML qw(LoadFile);
$config = LoadFile "$ENV{HOME}/.posterous";
my $req = HTTP::Request->new(GET => "http://posterous.com/api/getsites");
$req->authorization_basic($config->{core}->{user}, $config->{core}->{pass});
$content = LWP::UserAgent->new->request($req)->content;
$content =~ s/name/title/g;
print $content;
print Dumper XMLin($content);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment