Page 1 of 1

Newbie - Silly Question

Posted: Fri Jun 08, 2012 10:04 am
by mightec
Hi
I have just signed up to WURFL Cloud and I have downloaded the php files and created the quick example below.

<?php
// Include the WURFL Cloud Client
// You'll need to edit this path
require_once '../Client/Client.php'; What do I need to place here
// 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);
// 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";
}
?>

Re: Newbie - Silly Question

Posted: Fri Jun 08, 2012 10:16 am
by kamermans
Hi,

In the code sample you've posted, this line:

Code: Select all

require_once '../Client/Client.php';
Would need to be changed to the path to the WURFL Cloud Client's "/Client/Client.php" file. So, let's say your website content looks something like this:

Code: Select all

css/
images/
index.php
anotherpage.php
wurfl.php <-- this is the file that contains your code sample
WurflCloudClient/ <-- this is the WURFL Cloud Client code that you downloaded
  |- Cache/
  |- Client/
    |- Client.php <-- this is the file you need to include
  |- examples/
  |- HttpClient/
In that example, your code sample is inside wurfl.php, and so the require_once statement would need to be adjusted to the path of the Client.php file:

Code: Select all

require_once 'WurflCloudClient/Client/Client.php';
Does this answer your question?

Re: Newbie - Silly Question

Posted: Fri Jun 08, 2012 10:20 am
by mightec
Hi Steve
Yes, I think it does, I will try to work on from here, thank you.

EDIT: Sorry, I am using an Artisteer template within Joomla, I assume I place this in the template directory?

Re: Newbie - Silly Question

Posted: Fri Jun 08, 2012 10:25 am
by kamermans
Ok, no problem. One thing I didn't mention is that, if you are just running the example, you will not need to modify that path, since it's already correct. It only needs to be modified if you put this code in a different file, or move this file.

Re: Newbie - Silly Question

Posted: Fri Jun 08, 2012 10:28 am
by kamermans
You can indeed use the WURFL Cloud Client from a Joomla template, and you can place the client code in the templates directory if you wish.

Re: Newbie - Silly Question

Posted: Fri Jun 08, 2012 10:35 am
by mightec
Steve
Thanks again, I am using my server to try out the system.

thanks for your help.
bye