I used google API to get address from given GPS coordinates. But this address language that I got, isn’t suitable for me.
So I used also Google API for translation:
$from = 'en';
$to = 'tr';
echo "adress : " . "</br>".translate($from,$to,$address)."</br>";
function translate($from_lan, $to_lan, $text){
$data = file_get_contents ( "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=" . urlencode($text) . "&langpair=" . $from_lan . "%7C" . $to_lan );
$data = json_decode ( $data );
if ( $data->responseStatus == 200 )
{
$data = $data->responseData->translatedText;
}
return $translated_text;
}
But this code doesn’t work! The following error is occured :
Notice: Trying to get property of non-object in C:\wamp\www\getAddress.php
( $data = $data->responseData->translatedText; )
What shoud I do to solve this problem?
I think the API in question is no longer publicly available: