I'm generating a URL such as:
If I open this in browser, I'm getting a result successfully. However, if I use the same URL using curl
, I'm getting:
error:couldn't connect to host
Here is my PHP code
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=".urlencode('143 Blackstone Street, Mendon, MA - 01756')."&key=***********";
$ch = curl_init();
$options = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_TIMEOUT => 100,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => false
);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
if(curl_error($ch))
{
echo 'error:' . curl_error($ch);
}
curl_close ($ch);
print_r($response);
UPDATE
I came across a term called as server key
and browser key
when using the Google APIs. Howerver, in the API manager, I can't seem to see where to set or change the API type.