Is there an easy way to link TO events in my google calendar?
I'm migrating my library's website from webcal to google calendar. The site is written in PHP and HTML4.01 (moving from transitional towards stri开发者_如何学编程ct). Is there a programatic way that I can generate links to calender days/entries? With webcal a link to the day view was:
www.mylibrary.com/calendar/day.php?YYYYMMDD
And so it was easy to programatically generate a link to a specific day. I've been trying to find a way to do similar stuff w/ the google calendar and haven't had much luck. I'd really like to be able to do something like
<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>
Is this even remotely possible?
This might not be the "easy" solution you were hoping for but the Zend Framework has a gdata component that can do what you'd like.
The simplest way to include the calendar in your site is to use the Google provided embeddable calendar: http://code.google.com/apis/calendar/publish/. The upside is that all you have to do is toss the iframe code into a page and link to it. The downside is that, as far as I can tell, there's no mechanism for linking to a specific day or event.
To do something similar to what you're asking, you'll need to use the zend Gdata component and program it yourself. So, for days.php, you could do something similar to:
<?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>
Google Documentation: http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html
Zend Documentation: http://framework.zend.com/manual/en/zend.gdata.calendar.html
Much simpler solution:
if($_REQUEST['showday']!='') {$datetoshow=$_REQUEST['showday'];
$datetoshow = $datetoshow."/".$datetoshow;}
Blah blah page content
if ($datetoshow==""){?>
<iframe srtc=""> .... // regular embed text goes here.
<?} else {?>
<iframe src=""> // Add &mode=DAY&dates=<?echo $datetoshow;?> to the SRC code
<?}
Then it's as simple as calling the page w/ day.php?showday=20100205 or whatever day I want. Thanks for all the suggestions though!
精彩评论