Debian Codegraph @

dojox/rpc/tests/resources/jsonRpc10.php

raw symbols SCIP
1 <?php
2 require_once("./JSON.php");
3
4 // FIXME: doesn't look like we really need Pear at all
5 // which decreases the testing burden.
6 // Commenting out.the require and the new File() call.
7
8 // NOTE: File.php is installed via Pear using:
9 // %> sudo pear install File
10 // Your server will also need the Pear library directory included in PHP's
11 // include_path configuration directive
12 // require_once('File.php');
13
14 // ensure that we don't try to send "html" down to the client
15 header("Content-Type: application/json");
16
17 $json = new Services_JSON;
18 //$fp = new File();
19
20 $results = array();
21 $results['error'] = null;
22
23 $jsonRequest = file_get_contents('php://input');
24 //$jsonRequest = '{"params":["Blah"],"method":"myecho","id":86}';
25
26 $req = $json->decode($jsonRequest);
27
28 $method = $req->method;
29 $params = $req->params;
30
31 switch($method) {
32 case "postJsonRpc10EchoNamed":
33 case "postJsonRpc10Echo":
34 $results['result']=$params[0];
35 break;
36 default:
37 $results['result']="";
38 $results['error']="JSON-RPC 1.0 METHOD NOT FOUND";
39 break;
40 }
41
42 $results['id'] = $req->id;
43
44 $encoded = $json->encode($results);
45
46 print $encoded;
47 ?>