use LWP::UserAgent; use HTTP::Cookies; sub new { my $self = {}; my $apiphp = "http://localhost/wiki/api.php"; my $header = HTTP::Headers->new(Content_Type => "application/x-www-form-urlencoded"); my $cjar = HTTP::Cookies->new(file => "/root/perl/mediawiki/cookies/mediawiki.cookies", autosave => 1); my $client = LWP::UserAgent->new(default_headers => $header, cookie_jar => $cjar) || die "MWUser.pm LWP::UserAgent failed!\n"; my %login = ( 'action' => 'login', 'format' => 'xml', 'lgname' => 'user', 'lgpassword' => 'pass' ); my $r = $client->post($apiphp, Content=>\%login); while (my ($k, $v) = each (%$r)) { print "$k = $v\n"; } }