适用于PHP的Google日历API,用于获取日历事件的简单只读请求 [英] Google calendar API for PHP simple read-only request to get calendar events

查看:96
本文介绍了适用于PHP的Google日历API,用于获取日历事件的简单只读请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为网站编写一些简单的PHP代码,以使用Google的日历API V3获得对事件的公共Google日历列表的只读访问权限.我只需要在网页上显示日历中即将发生的事件的列表.我已阅读过开发人员文档,并查看了 入门部分 获取事件示例代码 ,但我有点困惑.我想知道:

I'd like to write some simple PHP code for a website, to get read-only access to a public Google calendar list of events using Google's calendar API V3. I simply need to display a list of upcoming events from the calendar on a web page. I've read the developer docs and looked at the getting started section and the get events example code but I'm a bit confused. I'm wondering:

  • 是否有一种更简单的方法来执行我需要的操作,从而避免了所有这些OAuth事务?有未经身份验证的访问方法吗?

  • Is there a simpler way to do what I need that avoids all this OAuth stuff? Is there a non-authenticated access method?

如果没有,看来我需要在code.google.com/apis/console/上设置我的应用程序的访问权限,然后生成ApplicationName,ClientID,ClientSecret,RedirectURI和DeveloperKey. ApplicationName DeveloperKey 非常简单,可以在Google控制台中找到.但是对于其他项目,我需要创建OAuth 2.0 ClientID,这需要我选择应用程序类型"是Web应用程序还是服务帐户.我的情况应该是什么?在这种情况下,不需要用户登录,因为我不需要访问他们的日历-这只是我需要访问的公共日历.

If not, It looks like I need to set up access for my app at code.google.com/apis/console/, and then generate an ApplicationName, ClientID, ClientSecret, RedirectURI and a DeveloperKey. The ApplicationName and DeveloperKey are straightforward enough to find in Google Console. But for the other items I need to create an OAuth 2.0 ClientID, which requires me to choose if the Application Type is a Web Application or a Service Account. What should it be for my scenario? In this scenario no user login should be required, as I'm not requesting access to their calendar-- it's just a public calendar I need access to.

什么是重定向URI以及如何使用它.我应该如何设置?

What is the Redirect URI and how does it get used. How should I set it up?

Google的API示例获取并在会话数据中缓存访问令牌.然后,代码注释说不要这样做,而应该使用数据库.严重地?我真的需要处理缓存访问令牌吗?如果是这样,Google API中是否有内置的DB缓存机制,或者您该如何处理?

Google's API sample gets and caches an Access Token in Session data. Then the code comments say not to do this, that you should use a database instead. Seriously? Do I really need to deal with caching the access token? If so, is there a built-in DB caching mechanism in Google API or how do you handle this?

我真的在寻找一种更简单的方法.欢迎您的指导!

I'm really looking for a simpler approach. Your guidance would be welcome!

谢谢.

推荐答案

我认为您正在考虑这个问题.如果您只需要访问 public 日历上的事件,那么有一种方法可以执行此操作而无需调用Google Calendar API和所有附带的复杂性.每个 public Google日历都有一个iCal提要,可以在特定的URL上对其进行查看,通常采用以下格式:

I think you're way overthinking this one. If you just need access to events on a public calendar, then there's a way to do this without invoking the Google Calendar API and all of the attached complexity. Every public Google Calendar has an iCal feed that can be viewed at a specific URL, usually in the form of:

http://www.google.com/calendar/ical/{OWNER}/public/basic.ics

其中{OWNER}是日历所有者的URL编码的电子邮件地址.

where {OWNER} is the URL-encoded email address of the owner of the calendar.

通过查看日历设置并滚动到日历详细信息"标签的底部,可以找到特定的URL.

You can find the specific URL by viewing the calendar settings and scrolling to the bottom of the Calendar Details tab.

这篇关于适用于PHP的Google日历API,用于获取日历事件的简单只读请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆