【发布时间】:2019-02-17 16:24:23
【问题描述】:
作为我正在开发的应用程序的一部分,我想提供一个假期列表。我正在尝试使用 Google API 来执行此操作。在写代码之前,我只是想看看返回的 JSON 是什么样子的。
我在 Google 中设置了一个帐户,获得了一个 API 密钥,并设置为使用 Google Calendar API。我对获取假期列表所需的 HTML 进行了研究,但似乎无法使其正常工作。我浏览了所有日历 API 文档,但没有找到任何有关检索假期列表的信息。以下是我尝试过的一些 URL,以及收到的回复。我在网上找到了所有这些 URL 示例(主要是在这里)。我已删除我的 API 密钥。
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
https://www.googleapis.com/calendar/v3/calendars/en.uk@holiday.calendar.google.com/events?key=myKey
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
Google 正在查看我的请求,但它们都是错误的。
我在网上找到的网址似乎曾经有效,但似乎不再有效。
关于如何使用它有任何更新吗?
更新:我尝试了以下答案的信息,现在我得到了:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
我在 Events:List API 参考的 Try This API 部分尝试了en.danish#holiday@group.v.calendar.google.com,我能够获取日期的 JSON。我不明白为什么它在 Try This API 中有效,但在 url 中无效。我试过的最新网址:
【问题讨论】:
-
你试过this SO post中的解决方案了吗?
-
是的。这就是我在问题中列出的 URL 之一。
标签: google-api google-calendar-api