Internet'te Google Translate API kullanımı için her yerde arama yaptım, ancak iniş eğitimini veya açıklamasını bulamadım. Yani, işte yaptığım şey:
Google API Konsolu'nda, this cevabını kullanarak SHA1 Fingerprint ile Public API erişimi altında bir anahtar oluşturdum. Ben oluşturmak ve bu kodla OkHttp kitaplığı kullanarak benim isteği göndermek Android stüdyoda Google Translate API'nin Android'de Kullanımı
: Burada gibi benim API konsolu böyle görünüyor
OkHttpClient client = new OkHttpClient();
String apiKey = "My API key";
String apiLangSource = "en";
String apiLangTarget = "de";
String apiWord = "Hello";
String googleApiUrl = "https://www.googleapis.com/language/translate/v2?key=" + apiKey + "&source=" + apiLangSource + "&target=" + apiLangTarget + "&q=" + apiWord;
Request request = new Request.Builder().url(googleApiUrl).build();
Log.d(TAG, "API STRING" + googleApiUrl);
Call call = client.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Request request, IOException e) {
Log.d(TAG , "HTTP CALL FAIL");
}
@Override
public void onResponse(Response response) throws IOException {
Log.d(TAG , response.body().string());
}
});
Bu iyi çalışır ama tepkisi üzerinde alıyorum:
{
"error": {
"errors": [
{
"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."
}
}
Burada sorun nedir? API'm doğru ayarlandı mı? Aramayı doğru bir şekilde yapıyorum (bazı kütüphaneler gördüm ama rehberlik yaptım)? Bu kütüphaneyi kullanmanın makul bir yolu var mı? Bu ne demek oluyor?
"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."
Bazı demo çağrılarının ücretsiz olduğunu düşünüyorum ve buradaki sorun bu değil.
Ben API yapılandırma iyi finished.U API tuş üzerinde yapılandırılan yanıt 'kısıtlama görebileceğiniz değil sanırım ve ben parmak izini çıkarmak ve o inşaat paketlediğinizde isteği –
match' etmez. Yani gerçekten kimlik doğrulama hatası. Google parmak izimi ve paketimi nasıl doğrular? – BabbevDan
Aynı sorunla karşılaşıyorum. @DannyBabbev, bunun için bir çözüm buldunuz mu? – Flo