Search code examples
phpcurlsteamsteam-web-api

Different answers to the same queries cUrl (Steam Market)


When in the browser you follow the link:

http://steamcommunity.com/market/priceoverview/?country=US%C2%A4cy=5&appid=570&market_hash_name=Gem%20of%20Taegeuk

Gives out { "success": false }, In headings 500 a mistake. But when I do the same inquiry through cUrl

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://steamcommunity.com/market/priceoverview/?country=US&currency=5&appid=570&market_hash_name=Gem%20of%20Taegeuk");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);   
$curl = curl_exec($ch);

In response, instead of json I get this:

‹ЄV*.MNN-.VІJKМ)N­яятКC4

Tell me how to fix this and what might be the cause of the error (500)?


Solution

  • The server return gzipped response (header Content-Encoding: gzip). So, you need auto encoding:

    curl_setopt($ch,CURLOPT_ENCODING, '');

    P.S. Browser unlike the curl unpacks the response automatically.