Sublime directory Surf the web anonymous Pagerank Monitor


posting forms with cURL

olaf
Mon 8 October 2007, 12:52 pm GMT +0200
Just got a checkout page ready to post data to the payment channel (iDEAL).

first I send the data within an array to the target server like:

$postData['orderid'] = $_POST['order_id'];
$postData['amount'] = $_POST['amount'];
$ch curl_init("https://i-kassa.rabobank.nl/rik/test/orderstandard.asp");
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_POSTFIELDS$postData);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
$data curl_exec($ch);
curl_close($ch);
?>


but the target file didn't got any information, I need to populate the values in a querystring like:

$ch curl_init("https://i-kassa.rabobank.nl/rik/test/orderstandard.asp");
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_POSTFIELDS"orderid=1235698&amount=500");
curl_setopt($chCURLOPT_RETURNTRANSFER1);
$data curl_exec($ch);
curl_close($ch);
?>


is this strange? look to me that a windows server accepting data different, while the first method works great in a lot of (linux ) applications

Nikolas
Mon 8 October 2007, 12:56 pm GMT +0200
Strange. I always use the first way and never got a problem.

Maybe there is something else that cause the problem?

olaf
Mon 8 October 2007, 01:04 pm GMT +0200
Strange. I always use the first way and never got a problem.

Maybe there is something else that cause the problem?
no, maybe the target script is bad :D

I use this script to convert the array:

if(!function_exists('http_build_query')) {
	
function 
http_build_query($data$prefix NULL$sep ''$key '') {
	
	
$ret = array();
	
	
foreach ((array)
$data as $k => $v) {
	
	
	
$k urlencode($k);
	
	
	
if (
is_int($k) && $prefix != null) {
	
	
	
	
$k $prefix.$k;
	
	
	
}
	
	
	
if (!empty(
$key)) {
	
	
	
	
$k $key."[".$k."]";
	
	
	
}
	
	
	
if (
is_array($v) || is_object($v)) {
	
	
	
	
array_push($ret,http_build_query($v,"",$sep,$k));
	
	
	
} else {
	
	
	
	
array_push($ret,$k."=".urlencode($v));
	
	
	
}
	
	
}
	
	
if (empty(
$sep)) {
	
	
	
$sep ini_get("arg_separator.output");
	
	
}
	
	
return 
implode($sep$ret);
	
}
}
?>

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional