Here I have problem in retrieving data from 3rd party API. I am using file_get_contents() function to fetch data form particular URL using PHP. I got output when pass that URL directly in browser But I am getting error in file_get_contents. I have no idea about it. can anyone help me. ?
$url= "http://************.com/gds/api/availabilities/134/1594/2016-04-24.json?api_key=1223*****";
//134 -> Origin id
//1594-> Destination id
//2016-04-28 -> Date
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n"
));
$context = stream_context_create($opts);
$availabilty = file_get_contents($url, false, $context);
echo "<pre>"; print_r($availabilty); exit;
I am getting response like,
{"response":{"code":401,"message":"gzip not passed as header parameters"}}
I have tried 'Curl' too. Both producing same result. Thanks in advance.