Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #6939

Experian Net Connect API -php

Newsgroups comp.lang.php
Date 2012-09-03 02:32 -0700
Message-ID <be4e08bc-dffd-4745-9af2-bbdeb5c4bdf3@googlegroups.com> (permalink)
Subject Experian Net Connect API -php
From vivek <vkapadnis@gmail.com>

Show all headers | View raw


Hi,
       i am trying to connect experian 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.experian.com/NetConnect" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.experian.com/NetConnect NetConnect.xsd">
<EAI>Y1OJYOYX</EAI>
<DBHost>STAR</DBHost>
<ReferenceId></ReferenceId>
<Request xmlns="http://www.experian.com/WebDelivery" version="1.0">
<Products>
<CreditProfile>
<Subscriber>
<Preamble>TBD2</Preamble>
<OpInitials>TN</OpInitials>
<SubCode>1958497</SubCode>
</Subscriber>
<PrimaryApplicant>
<Name>
<Surname>Adams</Surname>
<First>Nora</First>
<Middle>C</Middle>
</Name>
<SSN>666868483</SSN>
<CurrentAddress>
<Street>604 Cypress St Apt B</Street>
<City>Newburgh</City>
<State>IN</State>
<Zip>47630</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.experian.com/lookupServlet1?lookupServiceName=AccessPoint&lookupServiceVersion=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 “.experian.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 == "experian.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.

Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Experian Net Connect API -php vivek <vkapadnis@gmail.com> - 2012-09-03 02:32 -0700
  Re: Experian Net Connect API -php Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-03 09:07 -0400
    Re: Experian Net Connect API -php vivek <vkapadnis@gmail.com> - 2012-09-03 06:57 -0700
      Re: Experian Net Connect API -php Jerry Stuckle <jstucklex@attglobal.net> - 2012-09-03 10:35 -0400
  Re: Experian Net Connect API -php ledgerDeMain <mail@me.not.invalid> - 2012-09-03 12:48 -0700

csiph-web