0

I am trying to use the SO API (eg: http://api.stackoverflow.com/1.0/users/3) to get some data:

<?php

$data = file_get_contents('http://api.stackoverflow.com/1.0/users/3');
echo $data;

?>

But the returned contents are garbled. I tested it on a couple different servers, including http://codepad.viper-7.com/9GFvsM. Is it my code or the API?

SilentGhost
  • 307,395
  • 66
  • 306
  • 293
999999
  • 1,873
  • 3
  • 14
  • 20

1 Answers1

2

The response is gzipped. I recommend you use curl and set CURLOPT_ENCODING to gzip.

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539