PHP中的xml压缩格式数据

时间:2018-07-02 07:27:28

标签: php xml curl gzip gz

我试图使用php通过API检索一些数据,在API文档中说响应以“ ZIPPED XML格式数据”返回,我使用php curl调用api端点,我收到了以下响应

H4sIAAAAAAAEALVW32+bMBB+n7T/AfGeOmu6FwRIWVJpkVpaLe0y5c0xt4Bk7Mw/Bvnv52KTkpVEa+Q9Yd+dP999Z38mftCKgpLpxw9BEDcykqSACgdlnoTOFQZNRZlMQjeIGjMulNpFCNV1fVVPrrjYouvx+BP6cX+3bAG62ErmWOEk1II5aDmqSiK45D/ViPAqMnEjGxW2Sdg0gEIFTAUMV9DLxAZGCzk3nyWoJFRCw8H+LGGmhTAL7zjBFJzb4Vpks+eOQvO038HB7jwFLwkEVckeCNHCVDk2yLjpZpptuGY55GFv4el0j6PObf7ql/BLAyNvnUPbrL4u5mGgDFYSGmfJVPhX8ujfcLCAgmsJmZn2AKUSJdtehjklqvzdB9twTgGzy9BsU8l+xnNvCea5ACn9ol37hZt4glvqjRYbX2AKK19NePTY0G+wLTnzBDYzF12Jva8yC858lXlb4ZL6wmqUlaoL2xCj05LV+k7JXet0ufRFGB1U+FWyh3HeINhc2hfGzm1lXfiLVqaTGLXfztbXvXT6HKxuv5iII6sLtXKWvrwmMXIT5+prkwGZx+jI4qLaW5Nmy1WM7NDZ2xuQmrdz3JX72F9mD/WB+tidy3SqTY8wLbHZzZksCb2qhxi4OcdAtvbAQLY+z8B6kICb9xKQQR2sAVPM8ndS8PkcBUsgnOVY7P/bOWilOL0Hav4lBDMoznLE0vfFbJCmif9z0g1l+geRfyuyCwoAAA==

这是响应头,

array(26) { ["url"]=> string(121) "http://v2wsisandbox.retailexpress.com.au/dotnet/admin/webservices/v2/inventoryplanning/inventoryplanningservice.asmx?wsdl" ["content_type"]=> string(23) "text/xml; charset=utf-8" ["http_code"]=> int(200) ["header_size"]=> int(231) ["request_size"]=> int(740) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(1.103402) ["namelookup_time"]=> float(0.252853) ["connect_time"]=> float(0.417976) ["pretransfer_time"]=> float(0.418056) ["size_upload"]=> float(485) ["size_download"]=> float(1109) ["speed_download"]=> float(1005) ["speed_upload"]=> float(439) ["download_content_length"]=> float(1109) ["upload_content_length"]=> float(485) ["starttransfer_time"]=> float(1.103335) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["certinfo"]=> array(0) { } ["primary_port"]=> int(80) ["local_port"]=> int(47362) }

所以,我的问题是如何解压缩响应并获取xml响应,我尝试了base64_decode(gzuncompress(api response)),它说数据错误,有什么想法吗?

1 个答案:

答案 0 :(得分:0)

在这种情况下,您需要gzdecode(),

gzdecode(base64_decode($apiResponseString))