hCard to JSON bridge
// Many thanks to the authors of these libraries and to the microformats community.
// Demo: http://simplelogica.net/cajondesastre/hcard2json/index.php?url=http://11870.com/pro/19483
// Manuel González Noriega for Simplelógica. Hire us at http://simplelogica.net
include('hkit.class.php');
include('JSON.class.php');
$debug = true;
$status = '200';
$ct = 'text/plain';
$hKit = new hKit;
$json = new Services_JSON();
if ($_GET['url']) {
$result = $hKit->getByURL('hcard', $_GET['url']);
if ($result) {
$o = ($json->encode($result));
$ct = ($debug) ? 'text/plain' : 'application/json';
}
else {
$o = '404 Not Found';
$status = '404';
}
}
else {
$o = '400 Bad Request';
$status = '400';
}
header('Content-type: '.$ct);
switch($status) {
case '400':
header("HTTP/1.0 400 Bad Request");
break;
case '404':
header("HTTP/1.0 404 Not Found");
break;
case '200':
default:
header("HTTP/1.0 200 OK");
break;
}
print $o;