28, May 2012

posting forms with cURL - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: posting forms with cURL
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: posting forms with cURL  (Read 1253 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« on: Oct 08, 2007, 12:52:33 pm »

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

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Oct 08, 2007, 12:56:58 pm »

Strange. I always use the first way and never got a problem.

Maybe there is something else that cause the problem?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Oct 08, 2007, 01:04:48 pm »

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 Cheesy

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);
	
}
}
?>

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7203
Tags : curl ideal Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: posting forms with cURL
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 09:26:26 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.