I'm trying to call an API (mapquest) url from a shared host.
The url works fine, as it shows the expected JSON response when pasted in a browser.
However, I can't make it work from a php page.
I tried both curl
and file_get_contents
with no success.
I keep on getting HTTP/1.1 400 Bad Request
error...
Here is the code I use, which is quite basic...
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, TRUE);
$result=curl_exec($ch);
if(!$result){
exit ('cURL ERROR: '.curl_error($ch));
}
return var_dump($result);