PHPBuilder - HTTPS transactions with PHP Page 2



RSS Twitter
Articles Application Architecture

HTTPS transactions with PHP - Page 2

by: Matt Allen
|
July 30, 2000

What do I do?
There is a nifty little utilisty out there called cURL (http://curl.haxx.nu) that is run via command line or the EXEC() function in PHP. Here is an example of some PHP code that talks SSL.

<?php

$URL
="some.test.url.com/ecomms-test.php";

exec("/usr/local/bin/curl -m 120 -d \"$data\" https://$URL -L",$return_message_array$return_number);

for (
$i 0$i count($return_message_array); $i++) {
    
$results $results.$return_message_array[$i];
}

$res explode(",",$results);

if (
$res[0]=="0") {
    print 
"Passed !!";
} else {
    print 
"Failed :-(";
}

?>
Let's run though this code.
The $URL is obviously the server which is waiting for you secure post. The exec() function called the curl app and passed it the following parameters:
  1. -m 120 - this is the timeout in seconds
  2. -d $data - this is the data that willl be posted to the server, it is in "key=value&key=value" format.
  3. -L comes AFTER the location you are posting to.
The data is returned into $return_message_array, each new line being a new element in the array. $results ends up being a concatination of all the rows reutrned, just in case there was a line break in there $res becomes an array containing all the results, this example assumes the results where a comma seperated list, some other examples of common deliminators are "|" and ":".
This example relies on the first element in $res to be the "return code" from the bank, each institution has a different rule for this, so make sure your check up.

« Previous Page
1
|
2
|
3
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Matt Allen

Comment:



Comment:

(Maximum characters: 1200). You have characters left.