function wpr_detect_mobile_device() { try { $config = new WurflCloud_Client_Config(); $config->api_key = WPR_API_KEY; $client = new WurflCloud_Client_Client($config); $client->detectDevice(); return $client->getDeviceCapability('is_wireless_device'); } catch (Exception $e) { return wp_is_mobile(); } }
function mf_is_mobile_device() { try { $config = new WurflCloud_Client_Config(); $config->api_key = '673289:CNry9beZIoP38Kn2z1WRQcAU6Fqd0TwS'; $client = new WurflCloud_Client_Client($config); $client->detectDevice(); return $client->getDeviceCapability('is_wireless_device'); } catch (Exception $e) { return wp_is_mobile(); } }
/** * 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 the script below. */ /** * Include the WURFL Cloud Client file */ require_once dirname(__FILE__) . '/../Client/Client.php'; try { // Create a WURFL Cloud Config $config = new WurflCloud_Client_Config(); // Set your API Key here $config->api_key = 'xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // Create a WURFL Cloud Client $client = new WurflCloud_Client_Client($config, new WurflCloud_Cache_Null()); // Detect the visitor's device $client->detectDevice(); // Show all the capabilities returned by the WURFL Cloud Service foreach ($client->capabilities as $name => $value) { echo "<strong>{$name}</strong>: " . (is_bool($value) ? var_export($value, true) : $value) . "<br/>"; } } catch (Exception $e) { // Show any errors echo "Error: " . $e->getMessage(); }
$text['cloud']['none'] = 'You are unable to test the WURFL Cloud Service from this server because it lacks support for JSON.'; if ($php_class == 'full') { $text['php']['partial'] = 'Your PHP version is OK, but you do not have support for JSON decoding. You will need the "json" extension to use WURFL Cloud.'; $php_class = 'partial'; } } if ($run_test) { // Test WURFL Cloud $cloud_class = 'none'; try { $config = new WurflCloud_Client_Config(); $config->http_timeout *= 2; $config->api_key = $api_key; $cache = new WurflCloud_Cache_Null(); $client = new WurflCloud_Client_Client($config, $cache); $client->detectDevice($_SERVER, array('brand_name', 'model_name')); $cloud_class = 'full'; } catch (WurflCloud_Client_NoAuthProvidedException $e) { $cloud_class = 'partial'; $text['cloud'][$cloud_class] = 'Your server is able to access WURFL Cloud, but your API Key was not provided so it could not be tested.'; } catch (WurflCloud_Client_ApiKeyInvalidException $e) { $text['cloud'][$cloud_class] = 'Your server is able to access WURFL Cloud, but your API Key was rejected. Please verify your key and try again.'; } catch (WurflCloud_Client_AuthException $e) { $text['cloud'][$cloud_class] = 'Your server is able to access WURFL Cloud and your API Key is correct, but it is expired or has been revoked. Please contact <a href="http://www.scientiamobile.com/" target="_blank">ScientiaMobile</a> to get your API Key reinstated. Possible causes for this error: Your WURFL Cloud account is past due; Your API Key has been revoked due to abuse'; } catch (WurflCloud_Client_ConfigException $e) { $cloud_class = 'none';