Connect to TransUnion using PHP?
Posted: Sat Mar 03, 2007 2:44 pm
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello I am trying to connect to TransUnion to generate a report. The transunion site requires a certificate.
I am trying to connect but always receive no result from them. It appears the connection is being refused or the certificate is not being found. TransUnion has no support but they assure me I can connect using PHP! I converted the certificate to pem format using openssl and put it in C:/certs/TUNA.pem.
Any help would be appreciated.
Damon Doran
Below is how I try to connect:Code: Select all
$HOST = 'test.transunionnetaccess.com';
$LOCAL_CERT_PATH = 'C:/certs/TUNA.pem';
$LOCAL_CERT_PASSPHRASE = 'CARBONIFEROUS';
// REQUEST MESSAGE
$REQUEST = "TU4I0011 CREDIT REPORT BABS-03 0622Z 00005206XXX1N";
$REQUEST .= "CD0105BARBARA'S TEST ";
$REQUEST .= "SH011";
$REQUEST .= "NM011ABSOLUTE CRANBERRY ";
$REQUEST .= "PI01587382123 ";
$REQUEST .= "AD01122 PARK FANTASY ISLAND IL60750 ";
$REQUEST .= "RP0107000N I";
$REQUEST .= "OR01YBNYN";
$REQUEST .= "AI01 000000000";
$REQUEST .= "OD010201001 01";
$REQUEST .= "OD010104001 01";
$REQUEST .= "ENDS012";
// HTTP REQUEST HEADER
$header = "Host: $HOST\r\n";
$header .= "Content-Length: ".strlen($REQUEST)."\r\n";
$header .= "Connection: close";
// array with the options to create stream context
// define context options for HTTP request
// (use 'http' index, NOT 'httpS')
// define context options for SSL transport
$opts = Array();
$opts['http']['method'] = "GET";
$opts['http']['header'] = $header;
$opts['http']['content'] = $REQUEST;
$opts['ssl']['local_cert'] = $LOCAL_CERT_PATH;
$opts['ssl']['passphrase'] = $LOCAL_CERT_PASSPHRASE;
// create stream context, GET request and retrive POSTED response
//$filename = 'https://test.TransUnionNetAccess.com:3018/?ping';
$context = stream_context_create($opts);
$filename = 'https://test.TransUnionNetAccess.com:3018/';
$content = fopen($filename, 'r', false, $context);
$type = get_resource_type($content);
echo "got a <b>$type</b> resource<br>\n";
fpassthru($content);
fclose($content);feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]