I am trying to get data from http://api.stackoverflow.com/1.1/search?tagged=php .
I am using this code to get data from the API:
$url = "http://api.stackoverflow.com/1.1/search?tagged=php";
$json = file_get_contents($url);
$json_data = json_decode($json, true);
print_r($json);
But it is showing me nothing. I have also used curl to get the data, but it also shows nothing. Why isn't it showing me anything, and how can I fix that?
The response is gzipped, use
gzdecode
:They are returning you gzipped content as response. That's why it didn't work with your json decoding. Here is equivalent curl request.