XHTML-MP and mobile hCard - Barcamp Brighton Presentation

Posted by Mark on 2008-03-15 in , , ,
These following code notes accompany my Barcamp Brighton presentation, and have example code to use my WURFL API to create part of an hCard that enables mobile users to call and SMS directly from webpages.

Controller section

$ua = $_SERVER['HTTP_USER_AGENT'];
if(array_key_exists('HTTP_X_DEVICE_USER_AGENT',$_SERVER) AND $_SERVER['HTTP_X_DEVICE_USER_AGENT']) $ua = $_SERVER['HTTP_X_DEVICE_USER_AGENT'];
$device = unserialize(file_get_contents("http://www.markng.co.uk/wurfl/php/product_info.is_wireless_device,xhtml_ui/$ua"));

View section

<div class="tel">
  <span class="type">Mobile</span>
  <?php if ($device['product_info']['is_wireless_device']): ?>
    <a href="<?php echo $device['xhtml_ui']['xhtml_make_phone_call_string'] ?>+447828794899" class="value">07828 794899</a> 
    <a href="<?php if (!$device['xhtml_ui']['xhtml_send_sms_string'] OR $device['xhtml_ui']['xhtml_send_sms_string'] == 'none'): ?>sms:<?php else: 
echo $device['xhtml_ui']['xhtml_send_sms_string'] ?><?php endif ?>+447828794899">(sms)</a>
  <?php else: ?>
    <span class="value">07828 794899</span>
  <?php endif ?>
</div>

A slideshare or similar link will follow when the actual presentation has been done !

Leave a reply