Answer the question
In order to leave comments, you need to log in
Can Php + Google Autocomplete error be fixed?
There is a bunch of front to Nuxt back to Laravel.
When entering the city, I send the input data to the back and there I knock on Google for autocmplete.
$c_podkl = curl_init(); // инициализируем соединение
curl_setopt($c_podkl, CURLOPT_URL, "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Комсомоль&types=geocode&language=ru&key=AIzaSyAbLpRwGvEKJ0MwzoaXGvdh1jX8-1H$H"); // к этому URL будем подключаться
curl_setopt($c_podkl, CURLOPT_RETURNTRANSFER, 1); // возвращать, а не распечатываь результат
curl_setopt($c_podkl, CURLOPT_TIMEOUT, 0); // таймаут
$json_result = curl_exec($c_podkl); // подключаемся, получаем данные
curl_close($c_podkl); // закрываем соединение
dd($json_result);
"""
{
"error_message" : "API keys with referer restrictions cannot be used with this API.",
"predictions" : [],
"status" : "REQUEST_DENIED"
}
"""
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question