Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mixed up POST values in Perl script

Tags:

post

forms

cgi

perl

I need to send POST values to server url, and I'm using this code:

$ogone_ua = new LWP::UserAgent;
$ogone_response = $ogone_ua->post("http://server.url/", {
'ACCEPTURL' => 'http://server.url2',
'AMOUNT' => '1000',
'CURRENCY' => 'USD',
'LANGUAGE' => 'en_US',
'ORDERID' => '20130105220939',
'PSPID' => 'vukasin',
'SHASIGN' => '6AEE128943C7C896A6449FF7C2CE702222995B7F'
} );

but server receives:

POST / HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Host: athlon.herrpan.com:2389
User-Agent: SSL-AirKiosk/1.0
Content-Length: 206
Content-Type: application/x-www-form-urlencoded

LANGUAGE=en_US&ACCEPTURL=http%3A%2F%2Fserver.url2&SHASIGN=6AEE128943C7C896A6449FF7C2CE702222995B7F&CURRENCY=USD&AMOUNT=1000&PSPID=vukasin&ORDERID=20130105220939

Why it is not in order? The bank API needs POST values to be sorted, just like in code.

like image 954
user2444098 Avatar asked Sep 02 '26 03:09

user2444098


1 Answers

Hashes don't have an inherent order, so the order is lost before ->post is even called. However, POST (to which ->post passes its args) also accepts an array reference.

->post("http://server.url/", [
   ACCEPTURL => 'http://server.url2',
   AMOUNT    => '1000',
   CURRENCY  => 'USD',
   LANGUAGE  => 'en_US',
   ORDERID   => '20130105220939',
   PSPID     => 'vukasin',
   SHASIGN   => '6AEE128943C7C896A6449FF7C2CE702222995B7F',
]);
like image 134
ikegami Avatar answered Sep 03 '26 20:09

ikegami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!