我试图用LWP::UserAgent连接到服务器。我已经成功地在同一台服务器上使用LWP::UserAgent进行匿名搜索,但现在我必须使用“机密”内容,这需要在该服务器上使用身份验证。我使用了密码:
my $ua = LWP::UserAgent->new;
$ua->default_header('Content-Type' => "application/x-www-form-urlencoded");
$ua->default_header('Authorization' => "Basic ".$Authent);
my $resp = $ua->post($uri);服务器回复: error 400,必需的param: grant_type
那么,如何用LWP设置大类型参数呢?我没有找到任何关于大类型问题的页面。
我也尝试过:
$ua->default_header('grant_type' => "client_credentials");和
my $resp = $ua->post($uri, grant_type => "client_credentials");这三者都给出了完全相同的错误信息。我不知道该怎么做。
发布于 2014-10-23 13:08:12
塔-达!我找到了答案。
grant_type不是头部的东西,它属于身体。所以,这样做的工作方法是:
$ua->default_header('Content-Type' => "application/x-www-form-urlencoded");
$ua->default_header('Authorization' => "Basic ".$Authent);
my $resp = $ua->post($uri, Content => ['grant_type' => "client_credentials"]);不管怎样,谢谢你!
https://stackoverflow.com/questions/26526632
复制相似问题