summaryrefslogtreecommitdiff
path: root/includes/js/dojox/rpc/tests/resources/jsonRpcPostGetEcho.php
blob: 7db91538bacd8462c69a21e0f9750f741682dc27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
	require_once("./JSON.php");
	
	$json = new Services_JSON;
	$method = $_REQUEST["method"];
	$id = $_REQUEST["id"];
	$params = $_REQUEST["params"];
	$result = "";

	switch ($method){
		case "postJsonRpc10Echo":
		case "getJsonRpc10Echo":
		case "postJsonRpc10EchoNamed":
		case "getJsonRpc10EchoNamed":
			$p = $json->decode($params);
			$result = "{id:" . $id . ", 'result':'" . $p[0]. "', error:''}";
			break;
		case "postJsonRpc12Echo":
		case "getJsonRpc12Echo":
		case "postJsonRpc12EchoNamed":
		case "getJsonRpc12EchoNamed":
			$p = $json->decode($params);
		
			if ($p->message){
				$d = $p->message;
			}else{
				$d=$p[0];
			}
			$result = "{id:" . $id . ", 'result':'" . $d . "'}";
			break;
		default: 
			$result = "{id:'1','error':'Unknown Method', 'result':'this result only here for this test, shouldnt be here in real code'}";
			break;	
	}

	print $result;

?>