Debian Codegraph @

dojox/rpc/tests/resources/jsonRpcPostGetEcho.php

raw symbols SCIP
1 <?php
2 // ensure that we don't try to send "html" down to the client
3 header("Content-Type: application/json");
4
5 require_once("./JSON.php");
6
7 $json = new Services_JSON;
8 $method = $_REQUEST["method"];
9 $id = $_REQUEST["id"];
10 $params = $_REQUEST["params"];
11 $result = "";
12
13 switch ($method){
14 case "postJsonRpc10Echo":
15 case "getJsonRpc10Echo":
16 case "postJsonRpc10EchoNamed":
17 case "getJsonRpc10EchoNamed":
18 $p = $json->decode($params);
19 $result = "{id:" . $id . ", 'result':'" . $p[0]. "', error:''}";
20 break;
21 case "postJsonRpc12Echo":
22 case "getJsonRpc12Echo":
23 case "postJsonRpc12EchoNamed":
24 case "getJsonRpc12EchoNamed":
25 $p = $json->decode($params);
26
27 if ($p->message){
28 $d = $p->message;
29 }else{
30 $d=$p[0];
31 }
32 $result = "{id:" . $id . ", 'result':'" . $d . "'}";
33 break;
34 default:
35 $result = "{id:'1','error':'Unknown Method', 'result':'this result only here for this test, shouldnt be here in real code'}";
36 break;
37 }
38
39 print $result;
40
41 ?>