Page 1 of 1

Receiving Capability Info from known User Agent?

Posted: Tue Mar 06, 2012 1:40 pm
by djp120
Hi guys,

I've been through the code (to the best of my knowledge) and it appears I can set the HTTP GET request in the example files to include UA= my own agent.

It seems to recognising this ok. However, is returning the same web browser info. For example I am running

example.php?UA=Mozilla/5.0%20(iPhone;%20CPU%20iPhone%20OS%205_0_1%20like%20Mac%20OS%20X)%20AppleWebKit/534.46%20(KHTML,%20like%20Gecko)%20Version/5.1%20Mobile/9A405%20Safari/7534.48.3

However, it seems to be returning: generic web browser

What am i doing wrong?

All the best,

Dan

Re: Receiving Capability Info from known User Agent?

Posted: Tue Mar 06, 2012 1:44 pm
by kamermans
The cloud clients use Cookie Caching by default, so it's likely that this response is being returned from cache. For testing you can specify the Null Cache provider. Which language are you using?

Re: Receiving Capability Info from known User Agent?

Posted: Tue Mar 06, 2012 1:50 pm
by kamermans
I'm assuming you're using PHP. Here's an example of testing the client without caching and forcing a given user agent:

Code: Select all

<?php 
// Include the WURFL Cloud Client 
// You'll need to edit this path 
require_once '../Client/Client.php';
 
// Create a configuration object  
$config = new WurflCloud_Client_Config();  
 
// Set your WURFL Cloud API Key  
$config->api_key = 'xxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';   
 
// Create the WURFL Cloud Client  
$client = new WurflCloud_Client_Client($config, new WurflCloud_Cache_Null());  
 
// Detect your device  
$client->detectDevice(array('HTTP_USER_AGENT'=>'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7'));  
 
// Use the capabilities  
if ($client->getDeviceCapability('ux_full_desktop')) {  
    echo "This is a desktop web browser";  
} else {  
    echo "This is a mobile device";
} 
?>
Please note that I haven't tested this code, but it should be correct.

Re: Receiving Capability Info from known User Agent?

Posted: Tue Mar 06, 2012 2:13 pm
by djp120
That worked a treat, thanks Steve.

Code: Select all

$client = new WurflCloud_Client_Client($config, new WurflCloud_Cache_Null());