【发布时间】:2015-08-19 18:44:35
【问题描述】:
我想在我的 Android 应用程序中使用 Google Translate API (v2)。
我做了什么:
- 在 Google Developers Console 中创建项目
- 为此项目设置帐单
-
为 android 应用程序生成 2 个公共 api 访问密钥:
一个。第一个接受来自任何应用程序的请求
b.第二个只接受来自我的应用程序的请求
我尝试通过以下方式翻译应用程序中的文本 https://www.googleapis.com/language/translate/v2?key=MY-KEY&target=de&q=Hello%20world
它适用于 3a) 中的密钥,但不适用于 3b) 中的密钥。对于 3b) 服务器发送
{
"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."
}
}
我猜这是因为谷歌服务器没有收到关于我的应用程序的任何信息,所以它无法获取密钥 3b)。如果是这样,如何正确发送此请求?或者,或者,我在其他地方做错了什么?
【问题讨论】: