Forum Moderators: coopster

Message Too Old, No Replies

Using Keys to Get Values Out of An Array for Posting

         

cobalt30

3:03 am on Jan 7, 2010 (gmt 0)

10+ Year Member



I am trying to do a multi-hit on a payment gateway and the issue I'm running into is that I cannot figure out how to grab values from an array. The first hit is successful and returns 3 grid coordinates, of which I have to grab the respective values and return those values with other form data.

Here is part of my array:

$grid_array = array("A1" => "V", "A2" => "2", "A3" => "1", "A4" => "N", "A5" => "7", "B1" => "H", "B2" => "9", "B3" => "3", "B4" => "T", "B5" => "J", "C1" => "9", "C2" => "2", "C3" => "2", "C4" => "6", "C5" => "Y", "D1" => "N", "D2" => "1", "D3" => "R", "D4" => "8", "D5" => "K");

I can get the coordinates from the first hit which comes in XML as fields "response1", "response2", and "response3", but how do I code it so it grabs the appropriate value for me to send on the second hit through "challenge1", "challenge2", and "challenge3"?

Here is my post area:

curl_setopt($ch_pay, CURLOPT_POSTFIELDS, array
('login'=>$_POST['login'],
'pass'=>$_POST['pass'],
'paymentmethod'=>$_POST['paymentmethod'],
'billing_name'=>$_POST['billing_name'],
'billing_address'=>$_POST['billing_address'],
'billing_city'=>$_POST['billing_city'],
'billing_state'=>$_POST['billing_state'],
'billing_zipcode'=>$_POST['billing_zipcode'],
'billing_email'=>$_POST['billing_email'],
'frequency'=>$_POST['frequency'],
'SEC'=>$_POST['SEC'],
'startdate'=>$_POST['startdate'],
'amount'=>$_POST['amount'],
'cardholder_name'=>$_POST['cardholder_name'],
'cardnumber'=>$_POST['cardnumber'],
'cvv_code'=>$_POST['cvv_code'],
'expmon'=>$_POST['expmon'],
'expyear'=>$_POST['expyear'],
'response1'=>$grid_array[$xdoc1->challenge1],
'response2'=>$grid_array[$xdoc1->challenge2],
'response3'=>$grid_array[$xdoc1->challenge3]));

I know the formatting of the "response" fields are incorrect, so if there is any suggestions on how to pass that, I would appreciate it, because currently I get "Illegal Offset Type". And I've been trying to change it so much to make it work I don't even know what I had before or where to go with it.

TheMadScientist

9:15 pm on Jan 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hmmmm...

Well my official answer at this time is:

I don't use cURL. I don't want to use cURL. I'm not really sure what you are doing or how you are trying to send information anywhere from where you are now, because all I see is you setting an array of posted values and I'm really not sure where it's breaking, except on the last 3 array pieces being set...

But I can say Welcome to WebmasterWorld! and see if someone else has a better response than I do if you are still needing help with it.

cobalt30

9:26 pm on Jan 10, 2010 (gmt 0)

10+ Year Member



Thank you, but I did get it figured out and working. My issue was with the way the response tags were coded in the post fields. I found the correct syntax and now everything works great.

TheMadScientist

12:44 am on Jan 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Cool. Glad you got it figured out. I personally try to stick with 'nothing-fancy' PHP, but that's a discussion for another thread... LOL.

cobalt30

1:10 am on Jan 11, 2010 (gmt 0)

10+ Year Member



I had actually never used cURL until now (still very beginner with PHP). My cousin helped me code it, and I do like it from the standpoint that it handles multiple hits in the same page. Just learning what syntax to use was the tricky part. Hopefully one of these days I will get good enough with nothing fancy PHP. :)

Have a good week!