PHP Curl returning inconsistent data for XML feed PHP Curl returning inconsistent data for XML feed curl curl

PHP Curl returning inconsistent data for XML feed


The response is gzipped:

If you look at the HTTP headers:Content-Encoding: gzip

Unzip it with PHP:

gzinflate(substr($string, 10));

http://php.net/manual/en/function.gzinflate.php

Hope that helps... cheers


You should be able to send an empty Accept-Encoding header to the server and then it should not send the content gzipped or return a Not Acceptable response:

$string = file_get_contents(    "http://www.winnipegsun.com/home/rss.xml",    FALSE,    stream_context_create(        array(            'http' => array(                'method'  => "GET",                'headers' => 'Accept-Encoding:\r\n'            )        )    ));var_dump($string);

I am not sure the webserver is configured correctly though, because it wouldnt respond to that with the uncompressed feed, even when adding Cache Control headers telling to it not send a cached response. Oddly enough, just doing

$string = file_get_contents("http://www.winnipegsun.com/home/rss.xml?".time());

worked out of the box. And you can also send a POST request.