The question is about Google Translate API
I set a project and turn the billing on (with some money on the account)
I created a key for server app (also tryed to use a browser key) and added all 3 IPs I have (home and 2 servers)
What I see:
It does work in apis-explorer and in a browser address bar (https://www.googleapis.com/language/translate/v2/detect?q=an%20english%20text&key=MY_KEY)
-
It returns 403 error if I trying to get the same URL from PHP code:
$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, true);
$response = curl_exec($handle);
curl_close($handle);
print_r(json_decode($response, true));
thre result:
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.
))
I checked the IPs dozens of times, tryed to use browser key with allowed URL as referer. Out of ideas.