| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Parse iCalendar Example |
| 5 |
* |
| 6 |
* Enter an ics filename or URL on the command line, |
| 7 |
* or leave blank to parse the default file. |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
require_once("../zapcallib.php"); |
| 12 |
|
| 13 |
$icalfile = count($argv) > 1 ? $argv[1] : "abrahamlincoln.ics"; |
| 14 |
$icalfeed = file_get_contents($icalfile); |
| 15 |
|
| 16 |
// create the ical object |
| 17 |
$icalobj = new ZCiCal($icalfeed); |
| 18 |
|
| 19 |
echo "Number of events found: " . $icalobj->countEvents() . "\n"; |
| 20 |
|
| 21 |
$ecount = 0; |
| 22 |
|
| 23 |
// read back icalendar data that was just parsed |
| 24 |
if(isset($icalobj->tree->child)) |
| 25 |
{ |
| 26 |
foreach($icalobj->tree->child as $node) |
| 27 |
{ |
| 28 |
if($node->getName() == "VEVENT") |
| 29 |
{ |
| 30 |
$ecount++; |
| 31 |
echo "Event $ecount:\n"; |
| 32 |
foreach($node->data as $key => $value) |
| 33 |
{ |
| 34 |
echo " $key: " . $value->getValues() . "\n"; |
| 35 |
} |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|