我有一个嵌入在我的网站中的谷歌日历,但我希望能够从日历中提取事件详细信息(日期、时间、事件描述、地址)并使用 Angular 读取它,以便我可以重新格式化它并在我的页面上以我想要的方式显示它。
我不需要与它交互(意味着更新、删除、编辑任何内容),只需从中提取事件即可。
这可以通过 Angular API(或其他调用)实现吗?
最佳答案
是的,这是可能的,因为 Google 提供了 Google Calendar API
首先,您必须使用以下链接为您的日历启用 API: Google APIs wizard
然后您可以按照 Google 本身提供的 API 引用,只需对列出的端点执行 GET/POST 请求即可。
Google calendar API reference
编辑:作者询问了一些 Angular 示例来执行 HTTP 请求。
这是执行简单 GET 请求以获取 calendarId
条目的代码示例:
$http({
method: 'GET',
url: 'https://www.googleapis.com/calendar/v3/users/me/calendarList/' +calendarId
}).then(function successCallback(response) {
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
如果您问这样的问题,可能这个答案还不够,我认为这不是提供对该主题足够广泛的解释的最佳地点(而且可能我不是最好的老师) 。 看看官方Angular HTTP documentation更多示例和更完整的解释
关于angularjs - 如何使用 Angular 读取公共(public)谷歌日历中的事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37391311/