Obtaining an XML Feed from Events@Duke
Once a group's events are entered in Events@Duke, users can obtain an XML feed of a group's (or multiple groups') events. OIT developed the PHP and JavaScript code snippets below so departments could easily consume XML feeds and display events on their Web sites. If you need assistance obtaining or consuming feeds out of Events@Duke, contact the OIT Service Desk.
Note: Group names follow the format agrp_groupname. When you are logged into Event Administration, the group name is displayed in the page banner.
Direct XML feed
To obtain a calendar style XML feed for a group (or groups) out of Events@Duke, copy and paste the link below into your browser's address field. Replace groupname with the appropriate group name, or with a list of group names separated by commas. This feed will show events for the current week. Read more about feed types and parameters.
http://calendar.duke.edu/cal/main/setViewPeriod.do?skinName=feed&setappvar=group(agrp_groupname)&viewType=weekViewPHP code snippet
Use this code snippet to use PHP to consume an XML feed.
Note: PHP 5 or PHP's SimpleXML library must be installed (SimpleXML is bundled with PHP 5).
- Download and unzip the sample PHP code.
- At the top of the file, you'll find a number of configurations. On the line that states
$group = "agrp_NasherMuseumofArt";
replace agrp_NasherMuseumofArt with the name of your group, or with a list of group names, separated by commas. - Upload the file to your Web server.
- On the desired Web page, use PHP's "include statement" (http://us.php.net/include) to include the file in the desired location.
JavaScript code snippet
Use this code snippet to use JavaScript to consume an XML feed.
- Download the sample JavaScript code: jquery-1.2.3.js and event_calendar.js
- In the eventcal.js file, change
var eventContainer = "events";
to the id of the element you wish the events to appear in. - Upload the scripts to your Web server.
- Add the following two script tags to the <head> region of your page (make sure the src attribute is correct):
<script type="text/javascript" src="jquery-1.2.3.js"></script>
<script type="text/javascript" src="event_calendar.js"></script>
- Add a third script tag immediately preceding the closing </body> tag, and replace agrp_NasherMuseumofArt with your group's name, or a list of group names separated by commas:
<script type="text/javascript"
src="http://calendar.duke.edu/cal/main/showMain.rdo?
skinName=feedjs&setappvar=group(agrp_NasherMuseumofArt)"></script>
(The above script tag should be one line.)