Commit 469220b9 by Scott

Add JSON polyfill

json_encode and json_decode functions for use in PHP 5.1
parent 048db12d
......@@ -1602,6 +1602,26 @@
}
/**
* JSON compatibility layer for PHP 5.1
*/
if (!function_exists('json_encode') && !function_exists('json_decode')) {
require_once QA_INCLUDE_DIR.'vendor/JSON.php';
function json_encode($json)
{
$service = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
return $service->encode($json);
}
function json_decode($json)
{
$service = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
return $service->decode($json);
}
}
/*
Omit PHP closing tag to help avoid accidental output
*/
......@@ -46,16 +46,6 @@
$tourl=qa_path_absolute('');
if (strlen($app_id) && strlen($app_secret)) {
if (!function_exists('json_decode')) { // work around fact that PHP might not have JSON extension installed
require_once $this->directory.'JSON.php';
function json_decode($json)
{
$decoder=new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
return $decoder->decode($json);
}
}
require_once $this->directory.'facebook.php';
$facebook = new Facebook(array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment