0

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)?

Cœur
  • 37,241
  • 25
  • 195
  • 267
ToDoThis
  • 45
  • 6

2 Answers2

0

Two problems:

1) There's an additional %C2%A4cy% and missing curren after country=US in the example link. The URL in CURL looks ok.

2) Your CURL commands do not follow redirects, the URL should be with https:// (browser does that automatically). You can follow redirects with curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

Ondřej Mirtes
  • 5,054
  • 25
  • 36
0

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.

stdob--
  • 28,222
  • 5
  • 58
  • 73