in reply to POSTing with LWP::UserAgent
I've used the lazy approach to good effect.POST There is no simple procedural interface for posting data to a WWW serv +er. You must use the object oriented interface for this. The most common POST operation is to access a WWW form application: use LWP::UserAgent; $ua = new LWP::UserAgent; my $req = new HTTP::Request 'POST','http://www.perl.com/cgi-bin/BugG +limpse'; $req->content_type('application/x-www-form-urlencoded'); $req->content('match=www&errors=0'); my $res = $ua->request($req); print $res->as_string; Lazy people use the HTTP::Request::Common module to set up a suitable POST request message (it handles all the escaping issues) and has a suitable default for the content_type: use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua = new LWP::UserAgent; my $req = POST 'http://www.perl.com/cgi-bin/BugGlimpse', [ search => 'www', errors => 0 ]; print $ua->request($req)->as_string; The lwp-request program (alias POST) that is distributed with the library can also be used for posting data.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: POSTing with LWP::UserAgent
by Intaglio (Novice) on Jan 08, 2001 at 02:35 UTC | |
by tilly (Archbishop) on Jan 08, 2001 at 02:41 UTC | |
by Vautrin (Hermit) on Feb 07, 2004 at 15:24 UTC | |
by chipmunk (Parson) on Jan 08, 2001 at 02:45 UTC | |
by $code or die (Deacon) on Jan 08, 2001 at 03:29 UTC |