examples not working.

Questions about the WURFL Cloud service.
ubiquom
Posts: 3
Joined: Thu Mar 08, 2012 1:34 pm

examples not working.

Postby ubiquom » Thu Mar 08, 2012 1:39 pm

Hi:

According to the end time of Beta licence, I created a new key for new free licence.

but, no one of the code examples for PHP run on my service. internal system error. (using the new key too).

whats the easier example?

thanks.

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: examples not working.

Postby kamermans » Thu Mar 08, 2012 2:40 pm

Hi,

We will be keeping your beta keys active for at least a couple weeks in order to make the transition easier.

Could you tell me what version of PHP you are using?

Also, in your script, can you put these lines right after the opening <?php tag to enable error messages?

Code: Select all

ini_set("display_errors", "on");
error_reporting(E_ALL);
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

ubiquom
Posts: 3
Joined: Thu Mar 08, 2012 1:34 pm

Re: examples not working.

Postby ubiquom » Wed Mar 14, 2012 6:47 pm

Hi,

Thankyou.

Whats happening was too simple:
The name of new files in CLIENT folder are different than new ones.

New ones are Client.php
Older ones was WurflCloudClient.php

thats old.

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: examples not working.

Postby kamermans » Wed Mar 14, 2012 7:31 pm

Ah, I see, I will send out a message to the Beta users to let everyone know about the changes.
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

ubiquom
Posts: 3
Joined: Thu Mar 08, 2012 1:34 pm

Re: examples not working.

Postby ubiquom » Wed Mar 14, 2012 9:27 pm

...
examples/example.php runs fine. ( by using MyWurfl.php file)

examples/index.php source code doesn't

Code: Select all

Fatal error: Uncaught exception 'WurflCloud_Client_InvalidCapabilityException' with message 'The requested capability (max_image_width) is invalid or you are not subscribed to it.' in /var/www/vhosts/mypath/myapp/WurflCloudClient/Client/Client.php:339 Stack trace: #0 /var/www/vhosts/mypath/myapp/test.php(282): WurflCloud_Client_Client->getDeviceCapability('max_image_width') #1 {main} thrown in /var/www/vhosts/mypath/myapp/WurflCloudClient/Client/Client.php on line 339 The WURFL Cloud Test script was unable to run on your system
Error on line 339: Uncaught exception 'WurflCloud_Client_InvalidCapabilityException' with message 'The requested capability (max_image_width) is invalid or you are not subscribed to it.' in /var/www/vhosts/mypath/myapp/WurflCloudClient/Client/Client.php:339 Stack trace: #0 /var/www/vhosts/mypath/myapp/test.php(282): WurflCloud_Client_Client->getDeviceCapability('max_image_width') #1 {main} thrown
but visible minimal setup in in Compatibility Test Script output works fine too.

Code: Select all

// Use the capabilities 
if ($client->getDeviceCapability('is_wireless_device')) { 
    echo "This is a mobile device"; 
} else { 
    echo "This is a desktop device"; 
}

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: examples not working.

Postby kamermans » Wed Mar 14, 2012 11:03 pm

According to the exception, the script is failing because "The requested capability (max_image_width) is invalid or you are not subscribed to it." The likely cause is that you do not have the max_image_width capability selected for your account. Are you using default examples/index.php file from the 1.0 Cloud Client?
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

flindersuniversity
Posts: 5
Joined: Wed Mar 14, 2012 11:20 pm

Re: examples not working.

Postby flindersuniversity » Wed Mar 14, 2012 11:22 pm

Hi,

I'm not able to get any PHP code to work, based on the examples.
Here's the code of a page I've setup at one level above the /examples/ directory.
It doesn't get any errors, and the My Account display shows the detections going up, so the API is being used. Just no output!
I have setup these capabilities in my Account: is_wireless_device, is_tablet. I've tried both of them.
Thanks in anticipation

Chris

Code: Select all

<?php
ini_set("display_errors", "on");
error_reporting(E_ALL);
// Include the MyWurfl.php file
require_once './examples/MyWurfl.php';
// Get the is_wireless_device capability from the visiting device
$wireless = MyWurfl::get('is_tablet');
echo "complete";
?>

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: examples not working.

Postby kamermans » Wed Mar 14, 2012 11:36 pm

Can you post your error message? According to the script provided, you should just see "complete" on the screen - do you see this or is the screen blank? What do you see on the examples/index.php page?

Also, is_tablet and is_wireless_device are PHP Boolean values (true or false), so if you echo them directly you will see "1" for true and nothing for false. You can use this to print the values in human-readable form:

Code: Select all

$wireless = MyWurfl::get('is_tablet');
echo "Value: ".var_export($wireless, true)."<br/>\n";
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

flindersuniversity
Posts: 5
Joined: Wed Mar 14, 2012 11:20 pm

Re: examples not working.

Postby flindersuniversity » Wed Mar 14, 2012 11:43 pm

I checked the examples/index.php and discovered that I'd forgotten to put the api_key value in all the files.
I've done that, and now examples/index.php gives me a blank screen, as well as /examples/show_capabilities.php.
This is what my test file was doing.
(So not even the echo "complete" is showing up).

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: examples not working.

Postby kamermans » Wed Mar 14, 2012 11:48 pm

Sounds like something is intercepting your Exceptions, otherwise you would have seen an Invalid API Key Exception previously.

Can you try this?:

Code: Select all

<?php
try {
ini_set("display_errors", "on");
error_reporting(E_ALL);
// Include the MyWurfl.php file
require_once './examples/MyWurfl.php';
// Get the is_wireless_device capability from the visiting device
$wireless = MyWurfl::get('is_tablet');
echo "complete";
} catch(Exception $e) {
  echo "Caught ".get_class($e).": ".$e->getMessage();
}
?>
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

flindersuniversity
Posts: 5
Joined: Wed Mar 14, 2012 11:20 pm

Re: examples not working.

Postby flindersuniversity » Wed Mar 14, 2012 11:54 pm

I still get a blank screen with that code.
Unfortunately I'm quite new to PHP, and I'm not in control of the server. Perhaps something is capturing the messages.

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: examples not working.

Postby kamermans » Thu Mar 15, 2012 12:01 am

Ok, it sounds like you are on a shared hosting provider - can you tell me which one, so I can test their environment?

Also, can you run this code so I know a little more about the server?:

Code: Select all

<?php
echo "<pre>\n";
echo "uname: ".php_uname()."\n";
echo "version: ".PHP_VERSION."\n";
echo "CURL: ".(function_exists('curl_setopt')? 'YES': 'NO')."\n";
echo "fsock: ".(function_exists('fsockopen')? 'YES': 'NO')."\n";
echo "json: ".(function_exists('json_decode')? 'YES': 'NO')."\n";
echo "ob: ".var_export(ob_get_status(true), true)."\n";
echo "</pre>\n";
?>
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

flindersuniversity
Posts: 5
Joined: Wed Mar 14, 2012 11:20 pm

Re: examples not working.

Postby flindersuniversity » Thu Mar 15, 2012 12:55 am

Steve,

Here's the result from the test code:

uname: Linux aapep.cc.flinders.edu.au 2.6.18-274.el5PAE #1 SMP Fri Jul 8 17:59:09 EDT 2011 i686
version: 5.1.6
CURL: YES
fsock: YES
json: NO
ob: array (
0 =>
array (
'chunk_size' => 4096,
'type' => 1,
'status' => 0,
'name' => 'default output handler',
'del' => true,
),
)

The server is a virtual server in our computer room. There are multiple hosts on it (e.g. ehl.flinders.edu.au, www.flinders.edu.au,....). The only one I'm interested in is www.flinders.edu.au.

kamermans
Posts: 393
Joined: Mon Jun 06, 2011 9:50 am

Re: examples not working.

Postby kamermans » Thu Mar 15, 2012 8:21 am

Ah, I see the problem. You are missing JSON support - it was included since PHP 5.2.0 (released in 2006). One option is to have your server admin install the "json" extension via PECL, or you can grab a PHP script that replicates the functionality (this might work: http://www.php.net/manual/en/function.j ... php#100740). The reason the count is increasing on our side is that you are able to make the request, but not decode the response.
Thanks,

Steve Kamerman
ScientiaMobile

Make sure you check out our WURFL Cloud, WURFL InSight and WURFL InFuze products!

flindersuniversity
Posts: 5
Joined: Wed Mar 14, 2012 11:20 pm

Re: examples not working.

Postby flindersuniversity » Thu Mar 15, 2012 6:52 pm

That makes sense. But I think for now (while I'm evaluating) I might use the standalone version, to get more control.
I've tried adding on JSON support using http://www.php.net/manual/en/function.j ... .php#80606 but it still comes up blank.

Later this year our server should get upgraded and we should get PHP 5.2 then.

thanks

Chris


Who is online

Users browsing this forum: No registered users and 39 guests