<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Mort's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 26 Jul 2008 18:18:12 GMT</pubDate>
    <description>DZone Snippets: Mort's Code Snippets</description>
    <item>
      <title>hCard to JSON bridge</title>
      <link>http://snippets.dzone.com/posts/show/4102</link>
      <description>// Requires http://pear.php.net/pepr/pepr-proposal-show.php?id=198 and http://allinthehead.com/hkit&lt;br /&gt;// Many thanks to the authors of these libraries and to the microformats community.&lt;br /&gt;// Demo: http://simplelogica.net/cajondesastre/hcard2json/index.php?url=http://11870.com/pro/19483&lt;br /&gt;// Manuel Gonz&#225;lez Noriega for Simplel&#243;gica. Hire us at http://simplelogica.net&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;    include('hkit.class.php');&lt;br /&gt;    include('JSON.class.php');&lt;br /&gt;		&lt;br /&gt;    $debug = true;&lt;br /&gt;		&lt;br /&gt;    $status = '200';&lt;br /&gt;    $ct = 'text/plain';&lt;br /&gt;		&lt;br /&gt;    $hKit = new hKit;&lt;br /&gt;    $json = new Services_JSON();&lt;br /&gt;&lt;br /&gt;    if ($_GET['url']) {&lt;br /&gt;      $result = $hKit-&gt;getByURL('hcard', $_GET['url']);&lt;br /&gt;	    &lt;br /&gt;      if ($result) {&lt;br /&gt;	$o = ($json-&gt;encode($result));&lt;br /&gt;	$ct = ($debug) ? 'text/plain' : 'application/json';			&lt;br /&gt;      }&lt;br /&gt;      else {&lt;br /&gt;	$o = '404 Not Found';&lt;br /&gt;	$status = '404';&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;      $o = '400 Bad Request';&lt;br /&gt;      $status = '400';&lt;br /&gt;    }&lt;br /&gt;	&lt;br /&gt; &lt;br /&gt;&lt;br /&gt;  header('Content-type: '.$ct);&lt;br /&gt;  &lt;br /&gt;  switch($status) {&lt;br /&gt;    case '400':&lt;br /&gt;      header("HTTP/1.0 400 Bad Request");&lt;br /&gt;    break;&lt;br /&gt;	&lt;br /&gt;    case '404':&lt;br /&gt;      header("HTTP/1.0 404 Not Found");&lt;br /&gt;    break;&lt;br /&gt;&lt;br /&gt;    case '200':&lt;br /&gt;    default:&lt;br /&gt;      header("HTTP/1.0 200 OK");&lt;br /&gt;    break;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;print $o;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 03 Jun 2007 23:01:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4102</guid>
      <author>mort (Manuel Gonzalez Noriega)</author>
    </item>
  </channel>
</rss>
