Skip to content
Advertisement

how to decode Java stream in PHP

I requested Walmart report API and the result would be returned zip file stream.Refer to the API documents,it gives an example to realize it with Java code as the following below:

JavaScript

However,if I use php like:

JavaScript

It would download zip file but the file data is corrupt.It maybe such a reason like the byte stream is transfered by using Java code.It’s the problem about how to transform the bytes stream.Could you help me? By th way,I have cut parts of the stream as the following below:

JavaScript

Headers like this:

JavaScript

I just found that the transfer-encoding is chuncked.I’m not sure it’s this problem?

Advertisement

Answer

Did you resolve the issue? The below simple code worked for me

JavaScript

$response is the body of API response, which will be unreadable format $filename zip filename got from the header.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement