in reply to A regexp from paypal

You can post this script as a reply to your root node. Please wrap it in <code>...</code> tags so it renders and downloads nicely.

If the script is hand-rolling its own parameter decoding, it has likely other deficiencies. Normally, you want to use CGI.pm for handling all the CGI decoding.

Replies are listed 'Best First'.
Re^2: A regexp from paypal
by davidov0009 (Scribe) on Nov 25, 2007 at 21:33 UTC

    That is the funny thing, I am adapting a script put out by PayPal that had their own handrolled CGI and attempting to make it use the CGI module.

    The problem is I need to get a just the straight post string to add a parameter and send it off, param() isn't letting me do it. Any ideas on how to access the raw post string using the CGI module, right now the script does this:

    read (STDIN, $query, $ENV{'CONTENT_LENGTH'}); $query .= '&cmd=_notify-validate';
    There has to be something in CGI to do that read() line.
      Since CGI.pm gives you a couple of ways to fetch all the parameters it's passed, you could just add your new parameter to the list and then send it all back out using LWP.

      With a little bit of error checking, this could also save you from blindly sending back out any malformed data you receive.

        This is what I have so far
        #!/usr/bin/perl use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); my $q = new CGI; $q->param(-name=>'cmd',-value=>'_notify-validate'); # read post from PayPal system and add 'cmd' #read (STDIN, my $query, $ENV{'CONTENT_LENGTH'}); #$query .= '&cmd=_notify-validate'; # post back to PayPal system to validate use LWP::UserAgent; my ($ua,$req,$res); $ua = new LWP::UserAgent; $req = new HTTP::Request 'POST','http://www.eliteweaver.co.uk/testing/ +ipntest.php'; $req->content_type('application/x-www-form-urlencoded'); $req->content($q); $res = $ua->request($req);
        I need to add the cmd = _notify-validate name, value pair to the post string and then send it back out using LWP. When I send it out I am sending the CGI object itself out. ---- Now, here is some code that seems to do the trick well but I want to use the CGI module to do this (if possible) This is not my code, it is paypal's
        # read post from PayPal system and add 'cmd' read (STDIN, $query, $ENV{'CONTENT_LENGTH'}); $query .= '&cmd=_notify-validate'; # post back to PayPal system to validate use LWP::UserAgent; $ua = new LWP::UserAgent; $req = new HTTP::Request 'POST','http://www.paypal.com/cgi-bin/webscr' +; $req->content_type('application/x-www-form-urlencoded'); $req->content($query); $res = $ua->request($req);