我正在创建一个带有Perl后端的Facebook应用程序。问题是,由于Facebook将请求作为POST请求发送到我的Web应用程序,我在获取GET参数时遇到问题,这些参数也是应用程序的基本URL的一部分 - 实际上我只获得POST参数来自$ CGI-> Vars。
答案 0 :(得分:13)
请参阅CGI/MIXING POST AND URL PARAMETERS。
简短版本:对帖子参数使用$CGI->param()
,为查询字符串参数使用$CGI->url_param()
。
答案 1 :(得分:5)
转储CGI以支持更好的界面。 Plack的param
方法返回混合的GET和POST参数。
plackup -MPlack::Request -e 'sub {
my ($env) = @_;
my $r = Plack::Request->new($env);
return [200, ["Content-Type" => "text/plain"], [join "\n", $r->param("foo")]];
}'
> lwp-request -m POST -USe 'http://localhost:5000/fnord?foo=bar;baz=quux'
Please enter content (application/x-www-form-urlencoded) to be POSTed:
foo=123;baz=456
␄
POST http://localhost:5000/fnord?foo=bar;baz=quux
User-Agent: lwp-request/6.03 libwww-perl/6.03
Content-Length: 16
Content-Type: application/x-www-form-urlencoded
200 OK
Date: Thu, 27 Oct 2011 21:27:46 GMT
Server: HTTP::Server::PSGI
Content-Length: 7
Content-Type: text/plain
Client-Date: Thu, 27 Oct 2011 21:27:46 GMT
Client-Peer: 127.0.0.1:5000
Client-Response-Num: 1
bar
123
答案 2 :(得分:0)