diff --git a/include/ws_init.inc.php b/include/ws_init.inc.php index 444d87b29..6a318ddeb 100644 --- a/include/ws_init.inc.php +++ b/include/ws_init.inc.php @@ -58,6 +58,10 @@ if (!is_null($responseFormat)) include_once(PHPWG_ROOT_PATH.'include/ws_protocols/json_encoder.php'); $encoder = new PwgJsonEncoder(); break; + case 'jsonalt': + include_once(PHPWG_ROOT_PATH.'include/ws_protocols/jsonalt_encoder.php'); + $encoder = new PwgJsonAlternativeEncoder(); + break; case 'xmlrpc': include_once(PHPWG_ROOT_PATH.'include/ws_protocols/xmlrpc_encoder.php'); $encoder = new PwgXmlRpcEncoder(); @@ -66,4 +70,4 @@ if (!is_null($responseFormat)) $service->setEncoder($responseFormat, $encoder); } -set_make_full_url(); \ No newline at end of file +set_make_full_url(); diff --git a/include/ws_protocols/jsonalt_encoder.php b/include/ws_protocols/jsonalt_encoder.php new file mode 100644 index 000000000..a1294a378 --- /dev/null +++ b/include/ws_protocols/jsonalt_encoder.php @@ -0,0 +1,38 @@ + 'fail', + 'err' => $response->code(), + 'message' => $response->message(), + ) + ); + } + parent::flattenResponse($response); + return json_encode( + array( + 'stat' => 'ok', + 'result' => $response, + ) + ); + } + + function getContentType() + { + return 'application/json'; + } +} + +?> diff --git a/tools/ws.htm b/tools/ws.htm index e6807cd0f..8e1275fe4 100644 --- a/tools/ws.htm +++ b/tools/ws.htm @@ -133,7 +133,8 @@