php microformats samples - generate hCard and hCalendar entries
Sample code to generate hCard and hCalendar with PHP and phpMicroformats
PHP samples for generation of microformat entries
Sample code for encoding of a vcard
<?php
/*
* example php script that generates and outputs a hcard entry
*/
$myPersonalData = array(
'name' => 'Steve F. Better',
'email' => 'abuse-me@this-host-is-not-existing.info',
'org' => array(
'name' => 'The virtual company',
'title' => 'General chief of all'
),
'location' => array (
'street' => 'Main street 15b',
'town' => 'Mainhattan',
'zip' => '22912',
'state' => 'Main country',
'country' => 'Countrinidad'
),
'phone' => array(
'home' => '+1 123 66 71 292',
'cell' => '+1 123 88 72 121'
),
'photo' => 'http://enarion.net/img/phpsitemapng-170px.jpg',
'im' => array(
'skype' => 'echo-chinese',
'aim' => 'ShoppingBuddy'
)
);
require_once('phpMicroformats.class.php');
echo phpMicroformats::createHCard($myPersonalData);
?>
Sample code for encoding of a calendar event
<?php
/*
* example php script that generates and outputs a hcalendar entry
*/
$myEvent = array(
'name' => 'Release party of phpMicroformats',
'begin' => time(),
'end' => time()+2*60*60, // duration: 2 hours
'location' => array (
'street' => 'Main street 15b',
'town' => 'Mainhattan',
'zip' => '22912',
'state' => 'Main country',
'country' => 'Countrinidad'
),
'url' => 'http://enarion.net/phpmicroformats/'
);
require_once('phpMicroformats.class.php');
echo phpMicroformats::createHCalendar($myEvent);
?>