Net Connect API -php [message #179011] |
Mon, 03 September 2012 09:32 |
dev
Messages: 3 Registered: September 2012
Karma:
|
Junior Member |
|
|
Hi,
i am trying to connect xxx net connect api for credit profile details. i am developing this application in php. But i am getting "HTTP/1.1 303 See Other" Error.
Following is the curl code m executing,
<?php
$credit_profile = '<?xml version="1.0" encoding="UTF-8"?>
<NetConnectRequest xmlns="http://www.xxx.com/NetConnect" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xxx.com/NetConnect NetConnect.xsd">
<EAI>Y1OJYOYX</EAI>
<DBHost>STAR</DBHost>
<ReferenceId></ReferenceId>
<Request xmlns="http://www.xxx.com/WebDelivery" version="1.0">
<Products>
<CreditProfile>
<Subscriber>
<Preamble>TBD2</Preamble>
<OpInitials>TN</OpInitials>
<SubCode>2958499</SubCode>
</Subscriber>
<PrimaryApplicant>
<Name>
<Surname>Adams</Surname>
<First>Nora</First>
<Middle>D</Middle>
</Name>
<SSN>666868483</SSN>
<CurrentAddress>
<Street>704 Xypress St Apt C</Street>
<City>Newburgh</City>
<State>IN</State>
<Zip>97631</Zip>
</CurrentAddress>
<OutputType>
<XML>
<ARFVersion>07</ARFVersion>
<Demographics>Y</Demographics>
<Segment130>Y</Segment130>
<ScorePercentile>Y</ScorePercentile>
</XML>
</OutputType>
<Vendor>
<VendorNumber>FW2</VendorNumber>
</Vendor>
</CreditProfile>
</Products>
</Request>
</NetConnectRequest>';
$post_data = array('NETCONNECT_TRANSACTION'=> urlencode($credit_profile));
$username = 'API Username'; //
$password = 'API Password'; //
$user_pwd = base64_encode($username.':'.$password);
//#2-Net Connect client receives ECALS response. This is the Net Connect URL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ' http://www.xxx.com/lookupServlet1?lookupServiceName=AccessPoint&lo okupServiceVersion=1.0&serviceName=NetConnectDemo&serviceVersion=2. 0&responseType=text/plain');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$ecals_url = curl_exec($ch);
$info1 = curl_getinfo($ch);
curl_close($ch);
//#3-Net Connect client validates that the URL ends with ".xxx.com". If the URL is valid, the processing continues; otherwise, processing ends.
$host_name = parse_url( $ecals_url );
$host_name = explode(".", $host_name['host'] );
$host_name = $host_name[1].'.'.$host_name[2];
$ecals_url = trim($ecals_url);
if( $host_name == "xxx.com" )
{
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch1, CURLOPT_PORT, 443);
curl_setopt($ch1, CURLOPT_URL,$ecals_url);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch1, CURLOPT_TIMEOUT, 10000); //times out after 10s
curl_setopt($ch1, CURLE_SSL_CONNECT_ERROR, 1);
curl_setopt($ch1, CURLOPT_HEADER, 1);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch1, CURLOPT_POST,1);
curl_setopt($ch1, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch1, CURLOPT_USERPWD,$user_pwd);
curl_setopt($ch1, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded',"Content-length: ".strlen($credit_profile) ));
$result2 = curl_exec ($ch1);
$info = curl_getinfo($ch1);
if ( curl_errno($ch1) ) {
$result = 'ERROR -> ' . curl_errno($ch1) . ': ' . curl_error($ch1);
}
else {
$returnCode = (int)curl_getinfo($ch1, CURLINFO_HTTP_CODE);
switch($returnCode){
case 200:
$result = 'ReponseCode ' . $returnCode;
break;
case 302:
$result = 'ReponseCode ' . $returnCode;
break;
case 404:
$result = 'ReponseCode ' . $returnCode;
break;
default:
$result = 'HTTP ERROR -> ' . $returnCode;
break;
}
}
echo curl_error($ch1);
curl_close($ch1);
} // Ends If
?>
Please Advise.
|
|
|