View Single Post
Old 08-11-2009, 02:00 PM  
Bird
Confirmed User
 
Bird's Avatar
 
Join Date: Jan 2005
Location: Stockton
Posts: 4,365
[Tip] How Mobile Detection is Done!!!

For all of you that are just getting in to mobile, This is the first thing that needs to be done before starting your site. Hope this helps all of you get started.

You can download Tera-wurfl at
http://tera-wurfl.com/

installation video tutorial:

http://mmi.mobiquio.com/resources/wu...all%281%29.htm

Code:
<?php

// include the configuration and the class file

require_once('/home/user_account/public_html/yoursite/tera_wurfl/tera_wurfl_config.php');

require_once(WURFL_CLASS_FILE);



// instantiate the class

$myDevice = new tera_wurfl();



// get the capabilites from the user agent and take a look at the

// HTTP-ACCEPT headers in case the user agent is not found

$myDevice->GetDeviceCapabilitiesFromAgent($_SERVER['HTTP_USER_AGENT'],true);

$cap = $wurflObj->capabilities;




    if ( $myDevice->GetDeviceCapability('is_wireless_device') ) {

      switch ( $myDevice->GetDeviceCapability('preferred_markup') ) {

        case 'wml_1_1':

        case 'wml_1_2':

        case 'wml_1_3':

          $msite='http://yoursite.com/mobile';

          

          break;

        case 'xhtml_basic':

        case 'html_wi_w3_xhtmlbasic':

          $msite='http://yoursite.com/home/';

          

          break;

        case 'xhtml_mobileprofile':

        case 'html_wi_oma_xhtmlmp_1_0':

        case 'xhtml_mp_1.0':

          $msite='http://yoursite.com/mobile/';

         

          break;

        case 'html_wi_imode_html_1':

        case 'html_wi_imode_html_2':

        case 'html_wi_imode_html_3':

        case 'html_wi_imode_html_4':

        case 'html_wi_imode_html_5':

        case 'html_wi_imode_compact_generic':

          $msite='http://yoursite.com/mobile/';

 

          break;

        case 'html_web_3_2':

          $msite='http://yoursite.com/mobile/';



          break;

        case 'html_web_4_0':

          $msite='http://yoursite.com/home/';

          break;



		  

      }

      header("Location: $msite");



   } else {

      // Redirecting web browsers to another URL

      header("Location: http://yoursite.com/home");

    }


?>
__________________
ICQ:268731675
Bird is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote