Solved

RSS Feed import to other Calendar apps

Posted on 2011-02-22
5
2,526 Views
Last Modified: 2014-11-12
I have an RSS feed that is based on an internal calendar database app.

What's the best way to have people import that RSS feed into their own calendars regardless of what app they are using i.e. MS Outlook, Google Calendar, Lotus Notes etc...
I have attached the RSS feed page image.
calendar-rss-feed.bmp
0
Comment
Question by:awarraic
  • 3
  • 2
5 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 34961030
That's a good question and I have never tried to make an RSS feed into a calendar application - they are just two separate things.  However there may be a way by providing a link to a vCal file.

The <item> tag has a place for a link.
http://cyber.law.harvard.edu/rss/rss.html#hrelementsOfLtitemgt

This link could point to a script on your calendar application that generates a little vcal file, something like this.  The script is in the code snippet.
http://www.nationalpres.org/NPC_calendar_vcal.php?k=2945

Sorry it's not very pretty (legacy code from many years ago) but it works for our needs.

HTH, ~Ray
<?php // http://www.NationalPres.org/NPC_calendar_vcal.php
error_reporting(E_ALL ^ E_NOTICE);
$config_page = $_SERVER["DOCUMENT_ROOT"] . '/' . 'config.php';             require_once($config_page);
$cal_funcs   = $_SERVER["DOCUMENT_ROOT"] . '/' . 'calendar_functions.php'; require_once($cal_funcs);
if (bad_robots()) { die(); }



$_key        = $_GET["k"];
if (!is_clean_numeric_string($_key)) die("Bad Key");

$filename = "NPCEvent" . $_key . ".vcs";
header("Content-Type: text/x-vCalendar");
header("Content-Disposition: inline; filename=$filename");


$sql = "SELECT * FROM $calendar_table WHERE _key = $_key LIMIT 1 ";
if (!$result = mysql_query($sql)) { fatal_error($sql); }
$num_rows = mysql_num_rows($result);

if ($num_rows == 0) {
    echo "Sorry, the <b>Event Key $_key</b> is not found in the $calendar_table data base.<br /><br />\n";
    echo "Please report this error to the NPC Communications Office.<br /><br />\n";
    die("Sorry, Unable to add to your calendar.");
}
if ($num_rows != 1) {
    echo "SQL $sql<br>";
    echo "RESULT $result<br><br>";
    echo "The <b>Event Key $_key</b> appears to have $num_rows data base entries in $calendar_table (yikes!)<br />\n";
    echo "Please report this error to the NPC Communications Office.<br /><br />\n";
    die("Sorry, Unable to add to your calendar.");
}

$calendar_array = mysql_fetch_assoc($result); 

extract($calendar_array);

$loc = trim($location);
if ($loc  != '') { $loc = '=0D=0A=Location: ' . $loc; }

$poc1 = trim($poc1_name .' '. $poc1_phone .' '. $poc1_email);
if ($poc1 != '') { $poc1 = '=0D=0A=Contact: ' . $poc1; }

$poc2 = trim($poc2_name .' '. $poc2_phone .' '. $poc2_email);
if ($poc2 != '') { $poc2 = '=0D=0A=Contact: ' . $poc2; }

$pocw = trim($poc_url);
if ($pocw != '') { $pocw = '=0D=0A=WWW: ' . $pocw; }

$poc = $poc1 . $poc2 . $pocw;

// CALENDAR TOLERATES END TIMESTAMPS WRONG OR OMITTED - VCAL DOES NOT
$vcal_dtstart = date('Y-m-d\TH:i:sO', strtotime($start . " -1 hour"));
$vcal_dtend   = date('Y-m-d\TH:i:sO', strtotime($end . " -1 hour"));
if ($vcal_dtend < $vcal_dtstart) { $vcal_dtend = $vcal_dtstart; }


?>BEGIN:VCALENDAR
VERSION:1.0
PRODID:NPC Online Calendar
BEGIN:VEVENT
SUMMARY:<?php echo "$title" . PHP_EOL; ?>
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:<?php echo "$details" . "$loc" . "$poc" . PHP_EOL; ?>
DTSTART:<?php echo $vcal_dtstart . PHP_EOL; ?>
DTEND:<?php echo $vcal_dtend . PHP_EOL; ?>
END:VEVENT
END:VCALENDAR

Open in new window

0
 

Author Comment

by:awarraic
ID: 34974134
@Ray, how does this code work?
Do I have to add config.php and calendar.php files?
What's the $_key?
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 34974761
No, you do not have to add the config or calendar scripts from our framework - just substitute your own versions.  The only thing this script calls from the framework are error handlers, etc.  Should be pretty easy to figure out.

$_key is the key number for the row in the calendar table.  See line 9 where it is acquired and line 17 where it is used.
0
 

Author Closing Comment

by:awarraic
ID: 34979245
Thanks Ray. First time I heard about this Vcal thing, pretty cool. Once I created .ics file; I just dragged and dropped into lotus notes and all the events were in :)
Thanks again for all the help.
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 34983979
Thanks for the points.  I love the vCal.  There is a more advanced version of the standard now, but the older standard works perfectly and never confuses anyone.  Best regards, ~Ray
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This Micro Tutorial demonstrates the importance of annotations in Google Analytics and how they should be used to document changes made to a site, Google updates (Ex: Panda & Penguin), marketing campaigns, and any other events that might have contriā€¦
This Micro Tutorial will demonstrate how to use comments in Google Docs. You will learn how to create, edit, and delete a comment.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question