有没有简单的方法在我的Google日历中链接到事件?
问题描述:
我正在将我的图书馆网站从webcal迁移到Google日历。该网站是用PHP和HTML4.01编写的(从过渡到严格)。是否有一种可以生成日历/条目链接的编程方式?随着WebCal中的天视图中的链接是:有没有简单的方法在我的Google日历中链接到事件?
www.mylibrary.com/calendar/day.php?YYYYMMDD
所以很容易编程生成一个链接到一个特定的一天。 我一直在试图找到一种方法来做类似的东西W /谷歌日历,并没有太多的运气。我真的很希望能够做到像
<p>The summer reading program kicks off <a href="
<?php echo "http://www.google.com/calendar/event?cid=".$mycalenderid."&eventdate=".$year.$month.$day; ?>
">May 5th</a></p>
这是甚至是远程可能的吗?
答
更简单的解决:
if($_REQUEST['showday']!='') {$datetoshow=$_REQUEST['showday'];
$datetoshow = $datetoshow."/".$datetoshow;}
Blah blah页面内容
if ($datetoshow==""){?>
<iframe srtc=""> .... // regular embed text goes here.
<?} else {?>
<iframe src=""> // Add &mode=DAY&dates=<?echo $datetoshow;?> to the SRC code
<?}
然后就像调用页面w/day.php?showday = 20100205或我想要的任何一天一样简单。 感谢所有的建议,但!
答
在您的网站中包含日历的最简单方法是使用Google提供的可嵌入日历:http://code.google.com/apis/calendar/publish/。好处是你所要做的就是把iframe代码折腾到一个页面并链接到它。缺点是,据我所知,没有任何机制可以链接到特定的日子或事件。
要做类似于你所问的事情,你需要使用zend Gdata组件并自己编程。因此,对于days.php,你可以做类似的东西:
<?php
/**
* Adapted from google API doc example
*/
$day = $_GET['day'];
$nextDay = date('Y-m-d', strtotime($day) + 86400);
$client = new Zend_Gdata_Calendar(); //Not authenticated for public calendar
$query = $gdataCal->newEventQuery($client);
$query->setUser('[email protected]');
$query->setVisibility('public');
$query->setProjection('full');
$query->setOrderby('starttime');
$query->setStartMin($day); //Inclusive
$query->setStartMax($nextDay); //Exclusive
$eventFeed = $gdataCal->getCalendarEventFeed($query);
?>
<h1>
<?php print $day; ?>
</h1>
<ul id="days-events">
<?php foreach ($eventFeed as $event): ?>
<li class="event">
<?php print $event->title->text ?>
</li>
<?php endforeach; ?>
</ul>
谷歌文档: http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html
Zend的文档: http://framework.zend.com/manual/en/zend.gdata.calendar.html
只是为了补充一点,如果你还不知道。您不需要使用Zend Framework来使用它的某个组件。 – 2010-01-29 01:02:31
这将是我不得不安装服务器端?从长远来看,如果能让事情变得更简单,我并不反对前面有点困难。 – aslum 2010-01-29 01:43:33
以下是用于显示活动信息的文档:http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html#RetrievingEvents – emmychan 2010-01-29 08:19:23