Created
August 23, 2009 14:58
-
-
Save shelling/173326 to your computer and use it in GitHub Desktop.
using LWP with HTTP Basic Authentication
This file contains hidden or 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 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