Речь идет о Google Translate API
Я устанавливаю проект и включаю биллинг (немного денег на счету)
Я создал ключ для серверного приложения (также пытался использовать ключ браузера) и добавил все 3 IP-адреса, которые у меня есть (домашний и 2 сервера)
Что я вижу:
Он работает в apis-explorer и в адресной строке браузера (https://www.googleapis.com/language/translate/v2/detect?q=an%20english%20text&key=MY_KEY)
Он возвращает ошибку 403, если я пытаюсь получить тот же URL-адрес из кода PHP:
$ apiKey = 'MY_KEY';
$ url = 'https://www.googleapis.com/language/translate/v2/detect?q=an%20english%20text&key= '. $ apiKey. '';
$ handle = curl_init ($ url);
curl_setopt ($ handle, CURLOPT_RETURNTRANSFER, истина);
$ response = curl_exec ($ дескриптор);
curl_close ($ handle);
print_r (json_decode ($ response, true));
результат:
Array (
[error] => Array (
[errors] => Array (
[0] => Array (
[domain] => usageLimits
[reason] => ipRefererBlocked
[message] => There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.
[extendedHelp] => https://console.developers.google.com
))
[code] => 403
[message] => There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.
))
Я проверял IP-адреса десятки раз, пытался использовать ключ браузера с разрешенным URL-адресом в качестве ссылки. Нет идей.