How to POST content with an HTTP Request (Perl)

风流意气都作罢 提交于 2019-12-03 06:11:09
my $ua      = LWP::UserAgent->new(); 
my $request = POST( $url, [ 'port' => 8, 'target' => 64 ] ); 
my $content = $ua->request($request)->as_string(); 
Cole Tarbet

The answer given didn't work for me. I still had the same problem as OP.

The documentation for LWP::UserAgent wants a hash or array reference.

This works:

my $url = 'https://www.google.com/recaptcha/api/siteverify';
my $ua      = LWP::UserAgent->new(); 

my %form;
$form{'secret'}='xxxxxxxxxxxxxxxxxxxxxxx';
$form{'response'}=$captchaResponse;

my $response = $ua->post( $url, \%form ); 
my $content = $response->as_string();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!