2

我正在将我图书馆的网站从 webcal 迁移到 google 日历。该网站是用 PHP 和 HTML4.01 编写的(从过渡到严格)。有没有一种编程方式可以生成日历日/条目的链接?使用 webcal,指向日视图的链接是:

www.mylibrary.com/calendar/day.php?YYYYMMDD

因此,很容易以编程方式生成指向特定日期的链接。我一直在尝试找到一种方法来使用谷歌日历做类似的事情,但运气不佳。我真的很想能够做类似的事情

<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>

这甚至有可能吗?

4

3 回答 3

1

这可能不是您希望的“简单”解决方案,但 Zend 框架有一个gdata 组件可以做您想做的事情。

于 2010-01-29T00:58:33.830 回答
0

在您的站点中包含日历的最简单方法是使用 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('user@example.com');
$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

于 2010-01-29T09:16:06.583 回答
0

更简单的解决方案:

if($_REQUEST['showday']!='') {$datetoshow=$_REQUEST['showday'];
$datetoshow = $datetoshow."/".$datetoshow;}

胡说八道页面内容

if ($datetoshow==""){?>
<iframe srtc=""> .... // regular embed text goes here.
<?} else {?>
<iframe src=""> // Add &amp;mode=DAY&amp;dates=<?echo $datetoshow;?> to the SRC code
<?}

然后它就像调用带有 day.php?showday=20100205 或我想要的任何一天的页面一样简单。感谢所有的建议!

于 2010-02-01T21:13:58.670 回答