Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google api 如何构建指向google日历事件的html链接?_Google Api_Google Calendar Api - Fatal编程技术网

Google api 如何构建指向google日历事件的html链接?

Google api 如何构建指向google日历事件的html链接?,google-api,google-calendar-api,Google Api,Google Calendar Api,使用google日历API v3,我向google日历添加了一个事件。现在我想建立一个html链接,以便有人可以单击并查看日历事件 以下是我尝试过的: href看起来像: https://www.google.com/calendar/feeds/default/private/full/bigstringhere1ovmuup7mjf0 问题是我得到一个401错误“需要授权” 如何建立链接以根据google日历ID查看/编辑日历事件?要创建一个用户可以公开查看事件日历的页面,有权更改日历共享

使用google日历API v3,我向google日历添加了一个事件。现在我想建立一个html链接,以便有人可以单击并查看日历事件

以下是我尝试过的:

href看起来像:
https://www.google.com/calendar/feeds/default/private/full/bigstringhere1ovmuup7mjf0

问题是我得到一个401错误“需要授权”


如何建立链接以根据google日历ID查看/编辑日历事件?

要创建一个用户可以公开查看事件日历的页面,有权更改日历共享设置的用户必须首先公开日历:

  • 在谷歌日历的右上角,单击设置控制盘

  • 在“设置”中,单击“日历”选项卡

  • 单击您正在使用的日历的名称

  • 接下来,单击“共享此日历”选项卡。确保选中下面屏幕截图中的复选框(红色圆圈)


  • 然后,单击位于左上角的“日历详细信息”选项卡

  • 向下滚动至“日历地址”部分,如下面的屏幕截图所示

  • 点击“HTML”

  • 将出现一个弹出模式,其中包括您需要公开访问日历的公共URL



下面是URL的示例:

https://www.google.com/calendar/embed?src=domain.comrandomstring@group.calendar.google.com&ctz=America/Los_Angeles&gsessionid=OK

此外,有关创建和使用日历小工具的信息,请参见。事件URL不是日历URL

此链接提供了以下解释:

构建此url的方法是:

GET https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId
其中
calendarId
eventId
是参数


希望这是有帮助的。

谷歌已经创建了一个DIY页面


要从Google Calendar API v3获取事件,请调用:

GEThttps://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId

该事件包含一个属性
htmlink
,这正是您所需要的:

Google日历Web UI中此事件的绝对链接。只读

链接如下所示:

https://www.google.com/calendar/event?eid=XzYwcTMwYzFnNjBvMzBlMWk2MG80YWMxZzYwcmo4Z3BsODhyajJjMWg4NHMzNGg5ZzYwczMwYzFnNjBvMzBjMWc2c28zMmRoaDhwMGpnaDIxNnQyNDZkaGc2NG8zMGMxZzYwbzMwYzFnNjBvMzBjMWc2MG8zMmMxZzYwbzMwYzFnNzByNDRoMWk2b3AzOGUxazZoMms2aDFrNmQwamNkaTI2OHBrMmhpMjg4czRjZ2hoNzBwMF8yMDA2MDUwNSBob3BtYW4ubmxfbjE5ZGF2YWgxb3Zkb3EzbGl2N2t1aWU5Z.
当然,只有在您有权访问事件的情况下,它才会打开事件全屏。屏幕将包含返回日历的返回按钮


显然,您不能自己构造此链接,因此需要调用API,但您可能已经在这样做了。

有一种方法!要查看公共日历事件,请使用以下表单的链接:

https://www.google.com/calendar/event?eid={event-id}&ctz={timezone}
其中{event id}是唯一的事件id,{timezone}是其中之一

下面是一个例子:

如果您对该活动的日历具有编辑权限,则可以编辑该活动并查看来宾列表。否则,您只会看到有关该事件的公共信息

由于很难确定事件id,因此,在编辑谷歌日历事件的详细信息页面时,这里有一个bookmarklet,可以生成指向谷歌日历事件的链接:

javascript:(function(){ try { window.prompt('Shareable link to this event:','https://www.google.com/calendar/event?eid='+document.getElementsByClassName('ep')[0].getAttribute('data-eid')) } catch (e) {alert("Use this bookmarklet to get a shareable link to a Google Calendar event when editing its Details page.")}})()
以及此bookmarklet的一个版本,该版本与新的(截至2017年)谷歌日历用户界面配合使用:

javascript:(function(){ 
  window.prompt('Shareable link to this event:',
    'https://www.google.com/calendar/event?eid='+
    window.location.href.split("/").pop().split("?")[0])
})()
(也可能有用,如何链接到公共谷歌日历的特定日期:

https://www.google.com/calendar/embed?src={calendar-id}&mode=day&dates={yyyymmdd}%2F{yyyymmdd}
其中{calendar id}是日历的id,{yyyymmdd}是您要链接到的日期

可选参数包括时区和是否显示各种项目,例如:

&ctz=Asia/Taipei&showNav=0&showPrint=0&showCalendars=0

示例:)

我想发布这篇文章,因为它与所问的问题无关,而这篇文章是在我尝试执行以下操作时出现的

我试图生成一个Google事件,其唯一目的是添加到其他人的日历中,而不是保存到任何特定的日历中。我在这里找到了一个例子,目前我正试图找出它接受的URL参数

https://www.google.com/calendar/render?action=TEMPLATE&text=PRP+Due&dates=20141106T120000Z/20141106T120000Z&details&location&trp=false

以下是构建链接的HTML:


https://www.google.com/calendar/render?action=TEMPLATE&text=Your+事件+名称和日期=20140127T224000Z/20140320T221500Z&详细信息=对于+详细信息,+链接+此处:+http://www.example.com&location=Waldorf+Astoria,+301+Park+Ave+,+New+York,+NY+10022&sf=true&output=xml

按事件Id查看谷歌日历事件

您可以使用以下示例:

https://www.google.com/calendar/event?eid={event-id}&ctz={timezone}
印度时区示例:

https://calendar.google.com/calendar/event?eid=ZjVicWczYWpndmh0ZmdtYmd0cXFxZWc3czggdTJoZmoybGg0aDcwbmhzMzV2c25pamd1dG9AZw&ctz=Asia/Kolkata

当google日历事件创建时,我们在响应中得到了
result
属性。在这个
result
属性中,还有一个
htmlink
可以使用,其中包含与正在创建的事件相关的链接。现在,它可以打开:

window.open(response.result.htmlLink, '_target');

Wordpress+ACF google cal

将您的ACF日期选择器设置为自定义退货Y-m-d g:i a

然后创建一个谷歌格式的日期

$event_start_date = get_field('event_start_date');
$event_print_date = date('d/m/Y',strtotime($event_start_date));
$event_start_time = get_field('event_start_time');
$event_end_date = get_field('event_end_date');
$event_print_enddate = date('d/m/Y',strtotime($event_end_date));
$event_end_time = get_field('event_end_time');

$calendarDate = date('Ymd',strtotime($event_start_date)) .'T'. date('Hi',strtotime($event_start_time)). '00/' . date('Ymd',strtotime($event_end_date)) .'T'. date('Hi',strtotime($event_end_time)) . '00';
链接



日历是公共的吗?日历的所有者可能需要授予它公共读取权限。权限是公共的,我仍然会收到401错误。我认为这是可能的,因为在谷歌日历页面上,你实际上是点击了一个超链接来钻取和编辑活动细节。嗨,乔,你是想显示实际的日历还是仅仅显示提要?如果是源,那么这可能解释了它返回401的原因。“您尝试访问的网址(URL)无效。这可能是因为缺少部分URL。请检查您是否使用了完整的URL。(无效的“eid”参数)“即使在不同日历上的不同事件上,我也始终获得eid=$csei_goog_1362565475。编辑:没关系。我没有挽救这个事件。愚蠢的错误。这并没有回答OP的问题,但说明了如何制作一个按钮,在谷歌日历中为谷歌用户创建一个新的事件(提醒)。这个答案似乎不适用于OP的问题。您可以说明如何创建指向日历的链接,而OP需要指向事件的链接。我从日历设置中获得了我的(公共日历的)日历ID,并通过我在Google电子表格中编写的脚本获得了该事件ID,该脚本会转储某个事件的所有事件
<a href="https://www.google.com/calendar/render?action=TEMPLATE&text=<?php the_title(); ?>&dates=<?php echo $calendarDate; ?>&details=<?= strip_tags($event_contact_info); ?>  For+details,+link+here:+<?php the_permalink(); ?>&location=<?php echo $calendarLocation; ?>&sf=true&output=xml" target="_blank" rel="nofollow">Add this event to my Google Calendar</a>