|
HTTPS Transactions Via PHP
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:
- -m 120 - this is the timeout in seconds
- -d $data - this is the data that willl be posted to the server, it is in "key=value&key=value" format.
- -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.
[ Next Page ]
| Comments: | ||
| Example code snipit | Fred | 11/01/07 09:17 |
| HTTP_POST | ravi | 11/03/05 01:01 |
| RE: How can you execute a https request in Php? | deepa | 08/22/05 09:04 |
| RE: Atomic transactions? | William Gonzalez | 08/18/05 12:13 |
| Atomic transactions? | TheONE | 08/03/05 09:45 |
| RE: https | mile | 07/28/05 04:55 |
| RE: sending sms to india | Srinivas | 07/04/05 00:05 |
| Curl for transaction(Please help) | kiran | 01/27/05 07:29 |
| SEND SMS THrough web for free | Ranju | 11/28/04 14:30 |
| Meetul.Com | David | 09/04/04 03:58 |
| RE: ip chains (suggestion) | albee01 | 05/01/03 09:10 |
| Problem with PHP_AUTH_USER | Manilal | 03/22/03 02:09 |
| Refered, parameter -e | Jordi Lafortune | 03/04/03 15:51 |
| refered parameter -e | Jordi Lafortune | 03/04/03 15:47 |
| RE: sending sms to india | Pratap | 01/09/03 02:47 |
| RE: sending sms to india | Randomvariable | 12/07/02 04:41 |
| looking for a php bank programmer | ferdinand chekoua wansi | 10/23/02 08:10 |
| RE: Redirecting Urls | Gao | 10/17/02 10:55 |
| Redirecting Urls | Neena | 10/07/02 17:01 |
| Transferring files from php | Monx | 08/08/02 15:52 |
| RE: sending sms to india | Erl | 08/08/02 10:30 |
| RE: Project with PHP | Gaetano Giunta | 07/25/02 08:13 |
| RE: https | mahadev | 07/15/02 09:25 |
| Project with PHP | KOUAO | 07/10/02 11:47 |
| sending sms to india | peer mohamed | 06/29/02 11:34 |
| How can I install cURL on Windows ME | Barbara | 06/17/02 07:51 |
| PHP 4.3.0 fopen() and https | Alex | 06/15/02 07:38 |
| persistent connections across two pages | vito | 06/06/02 11:20 |
| cURL inaccessible | John | 05/31/02 16:19 |
| persistent connections | Jateen Mistry | 05/14/02 10:14 |
| RE: https | DIANA NIÑO | 04/26/02 16:04 |
| ok! But what about SSH? | pastaska | 04/17/02 05:07 |
| RE: HTTPS file transfers | Bela | 03/19/02 09:41 |
| HTTPs post to a server with authentication | George | 03/04/02 11:12 |
| cURL https post | George | 03/04/02 11:10 |
| Informations on HTTPS | Cedric | 02/13/02 11:45 |
| RE: ayuda | Juan Carlos González | 02/11/02 21:57 |
| RE: https | Jimmy | 02/09/02 14:56 |
| executable | hengky | 01/30/02 10:36 |
| RE: http://curl.haxx.nu doesn't exist | Wladimir - Br | 01/28/02 11:28 |
| https | Christiaan | 01/22/02 04:56 |
| curl seems not to return anything sometimes | Marian | 01/09/02 05:59 |
| Your suggestions Please | Rokishi | 12/29/01 11:02 |
| RE: XML File transfer | Per-Ingar Auberg | 12/21/01 16:44 |
| XML File transfer | erik-jan | 12/19/01 12:03 |
| RE: PHP with SSL | silviu | 12/18/01 06:57 |
| How save Session with Wml | leexiaobin | 11/28/01 08:25 |
| HTTPS file transfers | Dhayes | 09/05/01 15:18 |
| key to open any site | shahd_12 | 08/14/01 16:06 |
| ayuda | Juan José | 08/13/01 16:15 |
| ayuda | Juan José | 08/13/01 16:15 |
| Accessing http using https | Bob Tapia | 07/26/01 07:02 |
| RE: http://curl.haxx.nu doesn't exist | Liudas | 07/17/01 02:33 |
| posting data to a server | Nicole | 06/26/01 12:10 |
| Given URL incorrrect... | Robert J Sherman | 06/24/01 06:46 |
| RE: cURL for encryption ? | Jason Mowat | 06/14/01 12:43 |
| RE: cURL for encryption ? | juvalen | 06/05/01 12:45 |
| RE: Question | Vladimir | 05/30/01 05:50 |
| RE: How can you execute a https request in Php? | kimby | 05/22/01 06:11 |
| http://curl.haxx.nu doesn't exist | Rafael Bastidas | 05/21/01 12:31 |
| RE: PHP with SSL | Katie | 05/18/01 21:08 |
| How can you execute a https request in Php? | Deepesh | 05/12/01 04:17 |
| RE: cURL for encryption ? | dargyay | 05/08/01 12:50 |
| HUGE SECURITY PROBLEM | Eric Johanson | 05/02/01 19:44 |
| ip chains | faryal | 04/27/01 00:42 |
| RE: PHP with SSL | Chris von dyk | 03/23/01 00:02 |
| PHP with SSL | Paul | 03/05/01 06:23 |
| RE: cURL for encryption ? | Sezer YALÇIN | 02/07/01 01:31 |
| Great article.. and question... | Jose' L. Landivar | 01/23/01 03:08 |
| RE: cURL for encryption ? | Roger Harrell | 01/22/01 13:30 |
| cURL for encryption ? | Joey | 12/12/00 00:10 |
| vulnerability | vAr | 11/22/00 03:05 |
| https connections with PHP4 | eXeed | 10/07/00 10:44 |
| Question | Ryan | 09/21/00 22:43 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


