troubleshooting Question

CURL sending XML without spaces PHP

Avatar of Jamie Youell
Jamie Youell asked on
PHPXML* Curl
4 Comments2 Solutions706 ViewsLast Modified:
$xmlVariable = '<function name="AddFinancial">
              <component name="people">
              <property name="ppl_id"><![CDATA[34234424]]></property>
              </component>
              <component name="bankpayment">
              <property name="tlog_comment"><![CDATA[CURL, order ID: 242344]]>
              </property> <property name="tlog_evtt_id"><![CDATA[bpm]]></property>
              <property name="tlog_debit"><![CDATA[0]]></property>
              <property name="tlog_credit"><![CDATA[2.00]]></property>
              </component>
              </function>';

              $headers = array();
              $headers[] = 'Accept: application/xml';
              $headers[] = 'Content-Type: application/xml';

              $ch = curl_init();
              curl_setopt($ch, CURLOPT_URL, "https://test.testmanager.eu/API/Addfin.asp?api_license=234234");
              curl_setopt($ch, CURLOPT_POST, true);
              curl_setopt($ch, CURLOPT_POSTFIELDS, "input_XML=".$xmlVariable);
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
              curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
              curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
              curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
              curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0'); 

              $exe  = curl_exec($ch);
              $getInfo = curl_getinfo($ch);

The above CURL sends the XML to the URL but somehow removes all the spaces.

<functionname="AddFinancial"><componentname="people"><propertyname="ppl_id"><![CDATA[8DFB5500-6134-4220-9DB9-6FF841372C26]]></property></component><componentname="bankpayment"><propertyname="tlog_comment"><![CDATA[CURL,orderID:]]></property><propertyname="tlog_evtt_id"><![CDATA[bpm]]></property><propertyname="tlog_debit"><![CDATA[0]]></property><propertyname="tlog_credit"><![CDATA[2.00]]></property></component></function>
<functionname="AddFinancial"> should be <function name="AddFinancial">

 If tried using differt headers but until now nothing works. Any ideas? Thanks in advanced.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros