Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

post form URL encoded

by itko (Initiate)
on Jun 26, 2013 at 07:26 UTC ( #1040713=perlquestion: print w/replies, xml ) Need Help??

itko has asked for the wisdom of the Perl Monks concerning the following question:

Hi folks ! Just registered. I need to send to a Payment Gateway encrypted XML /base64/. Here are their requirements : ===================== 2.Parameter encryption Java

/String base64Xml = URLEncoder.encode(xml.toString(),"UTF-8"); sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder(); String base64 = encoder.encode(base64Xml.getBytes());


$base64 =base64_encode(urlencode($baseStr));
3.Data Submit <form action=“” method=“post”> <input type=”hidden” name=”TradeInfo” value=”<%= base64 %>”/> <input type=”submit” value=”submit” /> </form>

=================== I do everything to complete my XML then I encode it base64 and try to send. They said that cannot decode it. Why? - they dont know. Me too as I'm newby in Perl. They said that maybe my string is not correctly URL encoded...Here is the part of my sending :

#======= Encode XML base64 ================================ use MIME::Base64 ; $enco = encode_base64($wr); #======= Send request to Payment Gateway ================== use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua = LWP::UserAgent->new(); my $req = POST ''; [ type=>'hidden', name=> 'TradeInfo', value=> $enco, type=>'submit', value=>'submit', ]; $content = $ua->request($req)->as_string; # print "Content-type: text/html\n\n"; print $content;

====================== $enco is encoded string. When I sent them $enco in a file they decode it correctly. But when I send through Post method they cant I receive a error.jsp?error=1001 all the time I send Mybe something wrong in my post? Or ?.... Any help ??????????????????????????????????

Replies are listed 'Best First'.
Re: post form URL encoded
by Anonymous Monk on Jun 26, 2013 at 08:01 UTC
      Use POST() and your typos will be more obvious

      Another way to make typos and many other kinds of mistakes more obvious is to use the warnings and strict pragmata (as recommended in many basic debugging checklists):

      >perl -le "use warnings; use strict; ;; print qq{stringized array ref: }; [ a => 1, b => 2, ]; " Useless use of anonymous list ([]) in void context at -e line 1. stringized array ref:

      Update: diagnostics can also be helpful for the Perl/programming tyro.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: post form URL encoded
by MidLifeXis (Monsignor) on Jun 26, 2013 at 12:22 UTC

    I need to send to a Payment Gateway encrypted [emphasis added] XML
    Just a note on terminology. The calls I see you making indicate encoding, not encryption.


Re: post form URL encoded
by Anonymous Monk on Feb 18, 2020 at 21:39 UTC
    Did you find a solution for this issue. Cause of the issue could be that the base64 converted value has '+' and this will be converted to space on url encoding. I am in similar situation and searching for a solution.

      It has been seven years since the question was asked and that was the last time itko was here, so… :P

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1040713]
Approved by Happy-the-monk
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2020-04-10 10:51 GMT
Find Nodes?
    Voting Booth?
    The most amusing oxymoron is:

    Results (49 votes). Check out past polls.