Skip to content

Instantly share code, notes, and snippets.

@shelling
Created August 18, 2009 04:12
Show Gist options
  • Save shelling/169532 to your computer and use it in GitHub Desktop.
Save shelling/169532 to your computer and use it in GitHub Desktop.
basic http authentication example
#!/usr/bin/env perl
use LWP::UserAgent;
use HTTP::Request;
use MIME::Base64;
use YAML qw(LoadFile);
use Data::Dumper;
$config = LoadFile("$ENV{HOME}/.posterous");
$request = HTTP::Request->new(GET => "http://posterous.com/api/getsites");
$profile = encode_base64($config->{core}->{user} . ":" . $config->{core}->{pass});
$request->header( Authorization => "Basic $profile" );
$ua = LWP::UserAgent->new;
$response = $ua->request($request);
print $response->content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment