2010-01-29 59 views
2

我正在將我的圖書館網站從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> 

這是甚至是遠程可能的嗎?

回答

0

更簡單的解決:

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

Blah blah頁面內容

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

然後就像調用頁面w/day.php?showday = 20100205或我想要的任何一天一樣簡單。 感謝所有的建議,但!

1

這可能不是您希望的「簡單」解決方案,但Zend Framework有一個gdata component可以做你想做的事情。

+0

只是爲了補充一點,如果你還不知道。您不需要使用Zend Framework來使用它的某個組件。 – 2010-01-29 01:02:31

+0

這將是我不得不安裝服務器端?從長遠來看,如果能讓事情變得更簡單,我並不反對前面有點困難。 – aslum 2010-01-29 01:43:33

+0

以下是用於顯示活動信息的文檔:http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html#RetrievingEvents – emmychan 2010-01-29 08:19:23

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('[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

相關問題