trustpilot/developers — Issue #1: gzip decode unreliable
Author: quazmatron
Created: 2011-11-02 11:36:56+00:00
State: open

Sample code works fine on one of our trustpilot account, but the gzip decode returns zero data on another account.
Instead I used curl to retvieve the stream and deocde the gzip

$file = ( file_get_contents_curl("http://s.trustpilot.com/tpelements/xxxxxxxxxx/f.json.gz") );

function file_get_contents_curl($url)
{
$ch = curl_init();

curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch,CURLOPT_ENCODING , "gzip");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_URL, $url);

$data = curl_exec($ch);
curl_close($ch);

return $data;
}