25, July 2008

posting forms with cURL - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

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


It's time to use PHP5!


« on: Oct 08, 2007, 01: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


Last blog : 4th of July Lottery from TemplateMonster.com
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7975
40807 credits
Members referred : 3



« Reply #1 on: Oct 08, 2007, 01: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 Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Oct 08, 2007, 02: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);
	
}
}


Last blog : 4th of July Lottery from TemplateMonster.com
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....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Jul 25, 2008, 12:11:48 AM





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!


Forum Statistics
Total Posts: 35.717
Total Topics: 7.379
Total Members: 3.711
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: Asimina

39 Guests, 5 Users online :

12 users online today:



Readers

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