I am getting no responses from google places text search API
Here is my php code :
$string=$row["PropertyTitle"].'+'.$row["LocalityName"].'+'.$row["CityName"];
$details_url="https://maps.googleapis.com/maps/api/place/textsearch/json?query=".$city."&key=someapikey";
curl_setopt($ch, CURLOPT_URL, $details_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$geoloc = json_decode(curl_exec($ch), true);
print_r($geoloc);
it does not even give the below result
{
"html_attributions" : [],
"results" : [],
"status" : "INVALID_REQUEST"
}
What is the mistake i am doing and How can i fix this ?
Your are missing
$ch = curl_init();
And I guess your
$string
should be named$city
. Also, useurlencode
on$city
. See Why should I use urlencode?.