Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP CURL POST - xml response error
    primarykey
    data
    text
    <p>I am trying to get a XML response from an external service as shown below. Using php Curl to post info and receiving the response and trying to display in the browser.</p> <p>However I get the following error:</p> <blockquote> <p>XML Parsing Error: syntax error Location: Line Number 1, Column 1:<br> <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code><br> <code>^</code></p> </blockquote> <p>can you help me whats the source of this and what does this error imply? </p> <p>This is my code:</p> <pre><code>&lt;?php header ("Content-type: text/xml"); //defining $vars here...not shonw for simplicity $url = 'http://secure.leadexec.net/leadimport.asmx/LeadReceiver'; $myvars = '&amp;VID=' . $lead_id . '&amp;LID=' . '2' . '&amp;AID=' . $lead_id . '&amp;FirstName=' . $fname . '&amp;LastName=' . $lname . '&amp;Email=' . $email . '&amp;MoveDate='. $move_date . '&amp;Telephone=' . $phone . '&amp;Address=' . $address . '&amp;Website=' . $website . '&amp;Zip=' . $zipcode . '&amp;ServicesNeeded=' . $services . '&amp;RequestaQuote=' . $requestquote . '&amp;NumberofEmployees=' . $no_of_employees . '&amp;CompanyName=' . $company_name; $ch = curl_init(); curl_setopt( $ch, CURLOPT_VERBOSE, 1); curl_setopt( $ch, CURLOPT_URL, $url); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt( $ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); curl_setopt( $ch, CURLOPT_HEADER, 0); curl_setopt( $ch, CURLOPT_TIMEOUT, 40); curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars); curl_setopt( $ch, CURLOPT_POST, 1); $response = curl_exec($ch); if(curl_exec($ch) === false) { echo 'Curl error: ' . curl_error($ch); } else { echo 'Operation completed without any errors'; } $oXML = new SimpleXMLElement($response); foreach($oXML-&gt;entry as $oEntry){ echo $oEntry-&gt;title . "\n"; } if(curl_errno($ch)) print curl_error($ch); else print_r($response); curl_close($ch); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload