Пример #1
0
 /**
  * Initialize static instance
  */
 private static function init()
 {
     require_once dirname(__FILE__) . '/../Client/Client.php';
     // Additional configuration options can be used here
     $config = new WurflCloud_Client_Config();
     $config->api_key = self::$api_key;
     // These two lines setup the WurflCloud_Client and do the device detection
     self::$instance = new WurflCloud_Client_Client($config);
     self::$instance->detectDevice();
 }
Пример #2
0
 /**
  * Initialize static instance
  */
 private static function init()
 {
     require_once dirname(__FILE__) . '/../Client/Client.php';
     // Additional configuration options can be used here
     $config = new WurflCloud_Client_Config();
     $config->api_key = self::$api_key;
     // Set the cache that you'd like to use.  Here are some options:
     $cache = new WurflCloud_Cache_Cookie();
     //$cache = new WurflCloud_Cache_APC();
     //$cache = new WurflCloud_Cache_Memcache();
     //$cache = new WurflCloud_Cache_Memcached();
     //$cache = new WurflCloud_Cache_File();
     // These two lines setup the WurflCloud_Client and do the device detection
     self::$instance = new WurflCloud_Client_Client($config, $cache);
     self::$instance->detectDevice();
 }
Пример #3
0
 * WURFL Cloud Client - Simple example using MyWurfl
 * @package WurflCloud_Client
 * @subpackage Examples
 * 
 * This example uses the included MyWurfl class to get device capabilities.
 * If you prefer to use the WURFL Cloud Client directly, see show_capabilities.php
 * 
 * For this example to work properly, you must put your API Key in MyWurfl.php
 * and ensure that you have the following capabilities in your account:
 *  - ux_full_desktop
 *  - brand_name
 *  - model_name
 *  
 * (see below to run this example without the above capabilities)
 */
/**
 * Include the MyWurfl.php file
 */
require_once dirname(__FILE__) . '/MyWurfl.php';
try {
    // Check if the device is mobile
    if (MyWurfl::get('ux_full_desktop')) {
        echo 'This is a mobile device. <br/>';
        // If you don't have 'brand_name' and 'model_name', you can comment out this line to run the example
        echo 'Device: ' . MyWurfl::get('brand_name') . ' ' . MyWurfl::get('model_name') . " <br/>\n";
    } else {
        echo "This is a desktop browser <br/>\n";
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}