PHP code example of scientiamobile / wurflcloud

1. Go to this page and download the library: Download scientiamobile/wurflcloud library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

scientiamobile / wurflcloud example snippets


// Include the autoloader - edit this path! 
 new ScientiaMobile\WurflCloud\Config();  
// Set your WURFL Cloud API Key  
$config->api_key = 'xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';   
// Create the WURFL Cloud Client  
$client = new ScientiaMobile\WurflCloud\Client($config);  
// Detect your device  
$client->detectDevice();  
// Use the capabilities  
if ($client->getDeviceCapability('is_wireless_device')) {  
    echo "This is a mobile device";  
} else {  
    echo "This is a desktop device";  
}

// Common proxy examples
$http_client = new ScientiaMobile\WurflCloud\HttpClient\Curl();
 
// Socks 4 Proxy
$http_client->setProxy("socks4://192.168.1.1:1080");

// Socks 4a Proxy
$http_client->setProxy("socks4a://192.168.1.1:1080");

// Socks 5 Proxy
$http_client->setProxy("socks5://192.168.1.1:1080");

// Socks 5 Proxy + Authentication
$http_client->setProxy("socks5://someuser:[email protected]:1080");

// HTTP Proxy
$http_client->setProxy("http://192.168.1.1:8080");

// HTTP Proxy + Authentication
$http_client->setProxy("http://someuser:[email protected]:8080");

// Pass $http_client in to the Client to use it
$client = new ScientiaMobile\WurflCloud\Client($config, $cache, $http_client);

$http_client = new ScientiaMobile\WurflCloud\HttpClient\Curl();

// Timeout is in milliseconds (10000 == 10 seconds)
$http_client->setTimeout(10000);

// Pass $http_client in to the Client to use it
$client = new ScientiaMobile\WurflCloud\Client($config, $cache, $http_client);

$http_client = new ScientiaMobile\WurflCloud\HttpClient\FileGetContents();

$cache = new ScientiaMobile\WurflCloud\Cache\Memcache();

$cache = new ScientiaMobile\WurflCloud\Cache\File();

// Disable UNIX hard links since they aren't supported in Google App Engine
$cache->use_links = false;

// Update this to point to your Google Cloud Storage bucket
$cache->cache_dir = "gs://bucket_name/";

// Create a configuration object
$config = new ScientiaMobile\WurflCloud\Config();

// Set your WURFL Cloud API Key
$config->api_key = 'xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

// Create the cache adapter
$cache = new ScientiaMobile\WurflCloud\Cache\Memcache();

// Create the HttpClient adapter
$http_client = new ScientiaMobile\WurflCloud\HttpClient\FileGetContents();

// Create the WURFL Cloud Client
$client = new ScientiaMobile\WurflCloud\Client($config, $cache, $http_client);

// Detect device
$client->detectDevice();