troubleshooting Question

CURL sending XML without spaces PHP

Avatar of Jamie Youell
Jamie Youell asked on
4 Comments2 Solutions706 ViewsLast Modified:
$xmlVariable = '<function name="AddFinancial">
              <component name="people">
              <property name="ppl_id"><![CDATA[34234424]]></property>
              <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>

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

              $ch = curl_init();
              curl_setopt($ch, CURLOPT_URL, "");
              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"> should be <function name="AddFinancial">

 If tried using differt headers but until now nothing works. Any ideas? Thanks in advanced.
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