I am trying to include the Content-Length HTTP header in a call and I am struggling to get the length of the XML request string. I have sent a request with the API explorer which returned Content-Length in its response headers.
So I copied the XML and attempted to get the length from it with code as I know the length is 575, but the best I can do is return the length as 567. The code I used is below, if anyone can point me in the correct direction I will be very grateful.
$testXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<GetFeedbackResponse
xmlns=\"urn:ebay:apis:eBLBaseComponents\">
<Timestamp>2017-08-08T19:52:42.536Z</Timestamp>
<Ack>Failure</Ack>
<Errors>
<ShortMessage>User not found.</ShortMessage>
<LongMessage>The user "XXXXX" was not found in our database.</LongMessage>
<ErrorCode>21</ErrorCode>
<SeverityCode>Error</SeverityCode>
<ErrorParameters ParamID=\"0\">
<Value>XXXXX</Value>
</ErrorParameters>
<ErrorClassification>RequestError</ErrorClassification>
</Errors>
<Version>989</Version>
<Build>E989_INTL_API_18131002_R1</Build>
</GetFeedbackResponse>";
//length is 575 according to eBay
$testXml = new \SimpleXMLElement($testXml);
$testXml = $testXml->asXML();
$testXml = str_replace(" ", "", $testXml);
echo strlen($testXml);
//echos length 567