PHP:如何在使用fileget_contents()时使用HTTP_ACCEPT_ENCODING传递gzip接受?

I'm downloading once a day a large json output emitted wy a my webapi. My api server can output using gzip encoding, but it checks if to do this testing if HTTP_ACCEPT_ENCODING contains the word 'gzip'.

From webserver with the client script, I use file_get_content to read the json. But how to warn the api server that i'm able to accept gzip?

Apparently you can send headers (e.g. the HTTP_ACCEPT_ENCODING header) with your file_get_contents() request as described here.

An alternative could be using cURL to send the request with custom headers.