3

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.

4

1 回答 1

4

哈希没有固有的顺序,因此在->post调用之前顺序就丢失了。但是,POST->post将其参数传递给它)也接受数组引用。

->post("http://server.url/", [
   ACCEPTURL => 'http://server.url2',
   AMOUNT    => '1000',
   CURRENCY  => 'USD',
   LANGUAGE  => 'en_US',
   ORDERID   => '20130105220939',
   PSPID     => 'vukasin',
   SHASIGN   => '6AEE128943C7C896A6449FF7C2CE702222995B7F',
]);
于 2013-06-01T22:02:23.527 回答