1

I'm creating a facebook app with a Perl backend. The problem is that since Facebook sends the request to my web app as a POST request I'm having a problem getting the GET parameters that were also part of the base URL for the application -- in effect I'm only getting the POST params from $CGI->Vars.

0

3 Answers 3

13

See CGI/MIXING POST AND URL PARAMETERS.

Short version: use $CGI->param() for post paramenters and $CGI->url_param() for query string parameters.

Sign up to request clarification or add additional context in comments.

3 Comments

well the problem is that the URL is using get parameters to keep track of the application state, I guess the idea is to not mix get and post params -- other than it being part of the RFC standard I dont understand why this matters -- its not changing anything on the server, its just detecting which step to do
@nodebunny, Why what matters? Do you mean "why are they fetched using different methods"? To ensure that "Under no circumstances will the contents of the URL query string interfere with similarly-named CGI parameters in POSTed forms." This feature should be especially important to you according to what you said.
why it matters to keep GET and POST separated... but I think I understand the implications. You dont want to be able to set something as a GET param and it be treated a POST param, otherwise that defeats the purpose of having POST, right? However for my purposes I'm only looking for specific params so I guess its a mute point. The params I need whether its get or post doesnt matter. But I understand the situation better now. +1 for discussion
5

Dump CGI in favour of a better interface. Plack's param method returns GET and POST parameters mixed.

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 

Comments

0

Just set $CGI::APPEND_QUERY_STRING = 1;

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.