View Full Version : HTTP Response

02-11-2008, 07:19 AM
I'm working on a custom shopping cart for my wife's small work-at-home business. The cart is working as expected and I'm up where I need to transmit the data to the payment gateway.

Using a secure connection, we are transmitting the necessary data to the gateway. I have a form setup with the form action set to the gateway's server.

I can't seem to wrap my head around how to read the response from the gateway. The transaction responses are returned in the body of the HTTP
response in a query string name/value format delimited by ampersands. For
example: variable1=value1&variable2=value2&variable3=value3

So, once the buyer clicks "Checkout", the info is sent to the gateway, but how do I read the response?

Any insight would be greatly appreciated. (My wife bakes great cookies).

02-11-2008, 08:41 AM
take a look at the Zend framework's Http_Client, makes stuff like this really easy:

02-11-2008, 10:51 PM
Thanks GJay, I'll take a look.

But, in doing a little research it seems like this could be done fairly easily with cUrl.

Any thoughts?

02-12-2008, 12:10 AM
Yes, you should be using curl for this, though you can use list() to break apart the string if you really want to do it that way.

02-12-2008, 08:55 AM
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);


$client = new Zend_Http_Client('http://www.example.com');
$response = $client->request();
echo $response->getBody();

I know which one I'm more likely to understand in 6 months time, but in the simple case there isn't a lot in it.

02-12-2008, 09:25 AM
I went from using cURL to SOAP to Zend. I'd recommend using Zend as well if you can. Don't be inimidated by the framework.

02-12-2008, 06:24 PM
Thanx for the thoughts, guys. I'll checkout Zend.