Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

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:
  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.
[ Next Page ]

[Page 1]  [Page 2]  


Comments:
Example code snipitFred11/01/07 09:17
HTTP_POSTravi11/03/05 01:01
RE: How can you execute a https request in Php?deepa08/22/05 09:04
RE: Atomic transactions?William Gonzalez08/18/05 12:13
Atomic transactions?TheONE08/03/05 09:45
RE: httpsmile07/28/05 04:55
RE: sending sms to indiaSrinivas07/04/05 00:05
Curl for transaction(Please help)kiran01/27/05 07:29
SEND SMS THrough web for freeRanju11/28/04 14:30
Meetul.ComDavid09/04/04 03:58
RE: ip chains (suggestion)albee0105/01/03 09:10
Problem with PHP_AUTH_USERManilal03/22/03 02:09
Refered, parameter -eJordi Lafortune03/04/03 15:51
refered parameter -eJordi Lafortune03/04/03 15:47
RE: sending sms to indiaPratap01/09/03 02:47
RE: sending sms to indiaRandomvariable12/07/02 04:41
looking for a php bank programmerferdinand chekoua wansi10/23/02 08:10
RE: Redirecting UrlsGao10/17/02 10:55
Redirecting UrlsNeena10/07/02 17:01
Transferring files from phpMonx08/08/02 15:52
RE: sending sms to indiaErl08/08/02 10:30
RE: Project with PHPGaetano Giunta07/25/02 08:13
RE: httpsmahadev07/15/02 09:25
Project with PHPKOUAO07/10/02 11:47
sending sms to indiapeer mohamed06/29/02 11:34
How can I install cURL on Windows MEBarbara06/17/02 07:51
PHP 4.3.0 fopen() and httpsAlex06/15/02 07:38
persistent connections across two pagesvito06/06/02 11:20
cURL inaccessibleJohn05/31/02 16:19
persistent connectionsJateen Mistry05/14/02 10:14
RE: httpsDIANA NIÑO 04/26/02 16:04
ok! But what about SSH?pastaska04/17/02 05:07
RE: HTTPS file transfersBela03/19/02 09:41
HTTPs post to a server with authenticationGeorge03/04/02 11:12
cURL https postGeorge03/04/02 11:10
Informations on HTTPSCedric02/13/02 11:45
RE: ayudaJuan Carlos González02/11/02 21:57
RE: httpsJimmy02/09/02 14:56
executablehengky01/30/02 10:36
RE: http://curl.haxx.nu doesn't existWladimir - Br01/28/02 11:28
httpsChristiaan01/22/02 04:56
curl seems not to return anything sometimesMarian01/09/02 05:59
Your suggestions PleaseRokishi12/29/01 11:02
RE: XML File transferPer-Ingar Auberg12/21/01 16:44
XML File transfererik-jan12/19/01 12:03
RE: PHP with SSLsilviu12/18/01 06:57
How save Session with Wmlleexiaobin11/28/01 08:25
HTTPS file transfersDhayes09/05/01 15:18
key to open any siteshahd_1208/14/01 16:06
ayudaJuan José08/13/01 16:15
ayudaJuan José08/13/01 16:15
Accessing http using httpsBob Tapia07/26/01 07:02
RE: http://curl.haxx.nu doesn't existLiudas07/17/01 02:33
posting data to a serverNicole06/26/01 12:10
Given URL incorrrect...Robert J Sherman06/24/01 06:46
RE: cURL for encryption ?Jason Mowat06/14/01 12:43
RE: cURL for encryption ?juvalen06/05/01 12:45
RE: QuestionVladimir05/30/01 05:50
RE: How can you execute a https request in Php?kimby05/22/01 06:11
http://curl.haxx.nu doesn't existRafael Bastidas05/21/01 12:31
RE: PHP with SSLKatie05/18/01 21:08
How can you execute a https request in Php?Deepesh05/12/01 04:17
RE: cURL for encryption ?dargyay05/08/01 12:50
HUGE SECURITY PROBLEMEric Johanson05/02/01 19:44
ip chainsfaryal04/27/01 00:42
RE: PHP with SSLChris von dyk03/23/01 00:02
PHP with SSLPaul03/05/01 06:23
RE: cURL for encryption ?Sezer YALÇIN02/07/01 01:31
Great article.. and question...Jose' L. Landivar01/23/01 03:08
RE: cURL for encryption ?Roger Harrell01/22/01 13:30
cURL for encryption ?Joey12/12/00 00:10
vulnerabilityvAr11/22/00 03:05
https connections with PHP4eXeed10/07/00 10:44
QuestionRyan09/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.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.