Showing results for 
Search instead for 
Did you mean: 

Custom PHP cURL receives NULL Response

Hey everybody!


This is probably a very simple problem, but I don't know how to fix it.  My client wants a custom report of transaction data generated with the system and I don't have access to the server to be able to load up the SDK.  I think this is going to be no problem, but for some reason all I can get back from the sandbox is "NULL." 


Could someone please tell me what I'm doing wrong here?


$cert_path 	= dirname(__FILE__).'/ssl/cert.pem';

$test_url 	= "";
$prod_url 	= "";
$url 		= $test_url;

$api_id 	= "MY_LOGIN_ID";
$account_key 	= "MY_TRANSACTION_ID";
$request_type 	= "getSettledBatchListRequest";

$string 	= '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
$xml 		= @new SimpleXMLElement($string);
$merchant 	= $xml->addChild('merchantAuthentication');
$merchant->addChild('name', $api_id);
$merchant->addChild('transactionKey', $account_key);
$as_xml 		= $xml->asXML();

$ch 		= curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $as_xml);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 45);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if( file_exists($cert_path) ){ 
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
	curl_setopt($ch, CURLOPT_CAINFO, $cert_path); 
$result 	= curl_exec($ch);
echo curl_error($ch);
$result 	= json_decode($result, true);


I'm guessing it might be that I can't find the .xsd file in the SDK.  


Thank you in advance!


Hello @phpjayhawk

It doesn't look like anyone has responded yet, but someone still may have feedback on what you're looking for. I'd recommend subscribing to this topic so that you'll be alerted via email if anyone else from the community is able to respond with any comments. To subscribe, click Topic Options at the top of this thread and then select Subscribe. You'll then receive an email once anyone replies to your post.



Administrator Administrator

Thanks, @RichardH .


I will leave this up in the hopes that someone knows the answer, but I did resort to using the SDK and an answer to this issue is no longer neccesary for me.



I realize you have resorted to using the SDK, but for anyone who may be interested, below is what works for this particular API call and language:


$xmlContent = '<getSettledBatchListRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">

  $url = '';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlContent);
  $result = curl_exec($ch);
  echo $result;
Powered by -
Certified developers