Reputation: 2477
I have tried to use Reverse geocoding Webservice in PHP.Response JSON returns Empty response only.
$json_string2='http://maps.googleapis.com/maps/api/geocode/json?latlng=11.49813514,77.24331624&sensor=false';
$obj2=json_decode($json_string2);
$addr2=$obj2->formatted_address;
echo $addr2; //**line 1**
here line 1 prints empty....What is the problem in the coding....
Upvotes: 0
Views: 715
Reputation: 2558
Your problem is you did not get the file before decode to JSON and you also called with the wrong format.
$json_string2 = file_get_contents('http://maps.googleapis.com/maps/api/geocode/json?latlng=11.49813514,77.24331624&sensor=false');
$obj2 = json_decode($json_string2);
$addr2 = $obj2->results[0]->formatted_address;
echo $addr2; //**line 1**
you could try to print this object before you call its format.
print_r($obj2);
Upvotes: 1