按照本教程 http://www.androidhive.info/2012/01/android-json-parsing-tutorial,我对其进行了调整,以使用此URL"https://www.googleapis.com/calendar/v3/calendars/[calendar_ID]/events?singleEvents=true&orderBy=startTime&key=[my_API_key]"而不是示例中的URL来解析公共Google日历。此日历是公开的。
当我执行应用程序时,响应是这样的:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. The API is not enabled for your project, or 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 configuration.",
"extendedHelp": "https://console.developers.google.com"
}
],
"code": 403,
"message": "Access Not Configured. The API is not enabled for your project, or 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 configuration."
}
}
问题出在哪里?我做错了什么?
最后我找到了解决方案。
在这个URL https://www.googleapis.com/calendar/v3/calendars/[calendar_ID]/events?singleEvents=true&orderBy=startTime&key=[my_API_key]中,我使用的是Android应用程序的API密钥。当我为浏览器的 API 密钥更改此密钥时,问题消失了。