我正在使用Phonegap制作应用程序。在这个应用程序中,我想获取公共日历中的事件列表并显示它们。如何使用Phonegap使用Google日历JSON订阅源?
在浏览器中测试时工作正常,但使用设备时出现错误。
$.ajax({
url: url+'&timeMin='+today+'&key='+key,
type: 'GET',
dataType: 'json',
success: function(data)
{
//etc
错误消息:
{
"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."
}
}
我一直在使用这两种浏览器键和Android按键,从谷歌开发者控制台试过没有一个工作。我并没有真正尝试使用OAUTH来工作,因为这似乎是我想要完成的工作的矫枉过正。就像我说的,在浏览器中测试时,它工作正常。
我使用Phonegap Build来构建apk,所以我不知道是否有任何事情对我隐藏,可能会导致这种情况。
有关如何使这项工作的任何想法?
您是否在开发者控制台中启用日历API?此外,尝试将“查阅者”设置为“允许任何引用者”(如果该字段不是这样的话)(只是将字段留空)。 要执行此操作,请转至您的控制台并打开Api&auth/Credentials,然后单击“编辑允许的查阅者”清空输入字段。 – SGC
这实际上工作。我在Referrers领域有一个*认为是允许所有人。删除它并将字段留空即可解决问题。如果您重新提交此答案,我会将其标记为正确。 – Webemporious