Page 1 of 1

json_encode() Warning

Posted: Fri Mar 16, 2012 9:49 am
by PaulThomas
Hi,

Has any one experienced the following issue?

Warning: json_encode() expects exactly 1 parameter, 2 given in /home/xxxxxxx/public_html/Cache/Cookie.php on line 47

This error appears in the main desktop website. The following WURFL script is placed in the header. The error is on http://www.visioninwhite.com.au

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:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// 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')) {
header("Location: http://m.visioninwhite.com.au/");
}
?>
Thanks in advance for your help.

Cheers,
Paul

Re: json_encode() Warning - Solved

Posted: Fri Mar 16, 2012 10:28 am
by PaulThomas
I'm going to see how this fix pans out.

I found that the default handler for '$cookie_sent' was 'false' in Cookie.php on line 18. I have set it to 'true' and now the issue is resolved.

Code: Select all

class WurflCloud_Cache_Cookie implements WurflCloud_Cache_CacheInterface {
	public $cookie_name = 'WurflCloud_Client';
	public $cache_expiration = 86400;
	private $cookie_sent = true;
Hope this helps someone else!

Cheers,
Paul

Re: json_encode() Warning

Posted: Fri Mar 16, 2012 11:16 am
by kamermans
Hi Paul,

Thank you for your post. I am able to reproduce the issue with PHP versions less than 5.3.0. We will update the code to work without warnings in PHP < 5.3 and post back when the new version is available.

Re: json_encode() Warning

Posted: Fri Mar 16, 2012 11:52 am
by kamermans
There were some other changes in the queue, so we've released them as well as version 1.0.1, available from you account immediately.

Re: json_encode() Warning Solved

Posted: Fri Mar 16, 2012 12:42 pm
by PaulThomas
Hi Steve,

Thank you for the update. Yes, the PHP version we are using is 5.2.12. Will arrange an update to the latest PHP stable release!

Otherwise, the WURFL API is brilliant! 10 minute set up!

Cheers and thanks again.
Paul Thomas