我试图在调用中包含Content-Length HTTP标头,我正在努力获取XML请求字符串的长度。我已经向API资源管理器发送了一个请求,该请求在其响应标头中返回了Content-Length。
所以我复制了XML并试图通过代码获取它的长度,因为我知道长度是575,但我能做的最好的是将长度返回到567.我使用的代码如下,如果有人可以指出我正确的方向,我将非常感激。
$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