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);

Open in new window

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

<functionname="AddFinancial"> should be <function name="AddFinancial">

Open in new window

 If tried using differt headers but until now nothing works. Any ideas? Thanks in advanced.
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 2 Answers and 4 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 2 Answers and 4 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004