I'm trying to get some JSON results from an api, but it always returned me this error:
HTTP/1.1 400 Accept-Language HTTP header must be specified and be 'fr' or 'en' Cache-Control: no-cache Pragma: no-cache Expires: -1 Server: Microsoft-IIS/7.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Tue, 10 Dec 2013 15:31:59 GMT Content-Length: 0
I tried to put in my header: only the Accept-Language: fr, Accept-Language: fr, fr-ca, and all the header array you see below. There's my code
$url = 'http://safire.afiexpertise.com/api/Courses?divisionId=2';
$header = array('Accept: application/json, text/javascript, */*; q=0.01','Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3','Accept-Encoding: gzip, deflate','Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7','Content-Type: application/json; charset=utf-8','X-Requested-With: XMLHttpRequest','Pragma: no-cache','Cache-Control: no-cache');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, $header);
$data = curl_exec($curl);
curl_close($curl);
print_r($data);
It's the first time that an api ask me for that and i doesn't know much about curl http headers. I tried this header too http://php.net/manual/en/function.curl-setopt.php#Hcom78046 but no results.
Thank you to help me and / or show me how to find the answer.