RE: iCalendar creation not working with Outlook [SOLVED]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Okay, after much trial and error, I figured out the extremely annoying
issues... Here is a code fragment that should be very useful for anyone else
trying to make an iCalendar that works with Outlook...

I'm sure there's a better way to get the GMT time, as my way is a total
hack. I'm in PST btw, 7 hours from GMT, and I set the party events to be 6
hours long arbitrarily. Adjust as desired.

Outlook is EXTREMELY picky about the formatting and \n stuff
I found that using <?= $prow['party_name'] ?> for example didn't work. I'm
not sure if PHP puts an extra character or something, that's why I use the
echo instead and force a \n on there. The UID is required I think, didn't
seem to work without one. This part threw me off for a bit -- your
DESCRIPTION: must be ONE long line with  literal \n (not the escaped
version, but a \\n if you will). 

Another annoyance, is that if you split the time over multiple days, it
doesn't seem to want to play nice. It puts in two entries sorta. By sorta, I
mean, that if you look at the calendar you'll see one from 9pm-12am, then
another on the next day from 12am-3am for example. You can click either and
it brings up the same event. I would prefer one of those bars or something
that spans the days instead of the way it looks now. After much debugging
and experimenting, it seems this is a problem with Outlook. If an event
isn't longer than a certain amount of time, it doesn't warrant one of those
bars. Ugh! POS.

Anyways, to see this in action: 
http://www.rollinballzcrew.com/nextparty.phtml

-------------------- snip %< snip -----------------------

	if (isset($_GET['id']) && intval($_GET['id'] > 0))
	{
		$sql = "SELECT *, 
						UNIX_TIMESTAMP(party_date)
AS start, 
	
UNIX_TIMESTAMP(DATE_ADD(party_date, INTERVAL 6 HOUR)) AS end,
	
UNIX_TIMESTAMP(DATE_ADD(party_date, INTERVAL 7 HOUR)) AS GMTstart,
	
UNIX_TIMESTAMP(DATE_ADD(DATE_ADD(party_date, INTERVAL 6 HOUR), INTERVAL 7
HOUR)) AS GMTend,
	
UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL 7 HOUR)) AS GMTnow
				FROM 	party_table 
				WHERE 	party_id = ".intval($_GET['id'])."
LIMIT 1";
		//echo $sql;
		$pth = mysql_query($sql, $db);
		if ($pth && mysql_num_rows($pth) == 1)
		{
			$prow = mysql_fetch_array($pth,MYSQL_ASSOC);
			
	
//http://www.phpbuilder.com/columns/chow20021007.php3?page=2
			
			//http://www.sitellite.org/docs/Date/vCal.html
	
//http://www.scheduleworld.com/outlookInteroperability.html 
			//http://www.ietf.org/rfc/rfc2445.txt
			//http://www.linuxjournal.com/article/8159
			
		  	//$Filename = "RBC_Event" . $_GET['id'] . ".vcs";
			//header("Content-Type: text/x-vCalendar");
		    $Filename = "RBC Event [" . $_GET['id'] . "].ics";
		    header("Content-Type: text/Calendar");
			
		    header("Content-Disposition: inline;
filename=".$Filename);
			//$DescDump = str_replace("\r", "=0D=0A",
$prow['party_description']);
			$DescDump =
str_replace(array("\r\n","\r",'<p>','<P>','<BR>','<br>'), "\\n",
$prow['party_description']);
			$vCalStart = date("Ymd\THi00", $prow['GMTstart']);
			$vCalEnd = date("Ymd\THi00", $prow['GMTend']);
			$vCalNow = date("Ymd\THi00", $prow['GMTnow']);
?>
BEGIN:VCALENDAR
VERSION:2.0
PRODID:RBC Web Calendar
METHOD:PUBLISH
BEGIN:VEVENT
DTSTART:<?= $vCalStart ?>Z
DTEND:<?= $vCalEnd ?>Z
LOCATION:<?php echo $prow['party_location']."\n" ?>
TRANSP:OPAQUE
SEQUENCE:0
UID:1234567890<?= rand(1111111111,9999999999); ?>RBC
DTSTAMP:<?= $vCalNow ?>Z
DESCRIPTION:<?php echo $DescDump."\n"; ?>
SUMMARY:<?php echo $prow['party_name']."\n"; ?>
PRIORITY:1
X-MICROSOFT-CDO-IMPORTANCE:2
CLASS:PUBLIC
BEGIN:VALARM
TRIGGER:-PT60M
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR
<?php
			exit;
		}
		else
		if (!$pth) {	echo "<FONT
COLOR=#FF0000>Calendar<P><PRE>".mysql_errno().":
".mysql_error()."<BR></PRE></FONT>\n"; exit;	}
	} //if vcal

-------------------- snip %< snip -----------------------

> -----Original Message-----
> From: Daevid Vincent [mailto:daevid@xxxxxxxxxx] 
> Sent: Wednesday, July 06, 2005 5:53 PM
> To: php-general@xxxxxxxxxxxxx
> Cc: ceo@xxxxxxxxx
> Subject: RE:  iCalendar creation not working with Outlook
> 
> > *IS* it a Lunar based event, rather than Gregorian?...
> 
> Honestly, I don't even know what the difference is. All I 
> know is I want an
> event to appear on the date/time I gave it. I believe that 
> error message is
> NOT the true problem (google searches all point to "\n" being 
> the culprit)
> 
> > > It works fine in KOrganizer (KDE), Entorage (Mac OS-X), 
> > > iCal. I couldn't figure out how to get Evolution to use it.
> > 
> > What works fine?
> > 
> > The event?
> 
> Yes. If someone using KDE clicks on the link, it puts an 
> entry in their
> KOrganizer. If someone with Entourage clicks, it goes to 
> iCalendar. And
> since my post, a friend that uses Evolution, clicked, saved 
> the .ics file,
> and imported it into Evolution via their import wizard 
> (Evolution apparently
> isn't smart enough to directly import via the web).
> 
> > Are you suggesting that Outlook might not have implemented the full
> > specification, and has some hokey hacked-up crap instead?  
> > Say it's not true!
> > [that was sarcasm, in case you missed it...]
> 
> Yeah. I get the sarcasm. Unfortunately, that's not helping. 
> 90% of the world
> uses Outlook.
> 
> > > I find tons of people complaining on Google about this 
> > error message, but
> > > no
> > > real solution but to use "\n" -- which I have done I think. 
> > I have even
> > > commented out the DESCRIPTION field, and that didn't help.
> > >
> > > Does anyone have a real working example, class, snippet, 
> > whatever for an
> > > iCalendar generator that works in Outlook?
> 
> > Dump out a working Outlook iCalendar item/entry/object thingie.
> > Get the output from your code.
> > Where are they different?
> 
> Yes. I supposed that is the next step. I just thought there 
> might exist a
> class or snippet out there that actually works. I mean, you'd 
> think that
> this was a pretty common task, yet the PEAR site has nothing! 
> And I found
> one tutorial, which obviously is outdated and therefore 
> slightly broken.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux