开发者

file_get_contents() returns garbled data

开发者 https://www.devze.com 2023-01-18 22:59 出处:网络
I am trying to use the SO API (eg: http://api.stackoverflow.com/1.0/users/3) to get some data: <?php

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 c开发者_C百科ontents are garbled. I tested it on a couple different servers, including http://codepad.viper-7.com/9GFvsM. Is it my code or the API?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号