Debian Codegraph @

dojox/rpc/tests/resources/jsonRpc12.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 "postJsonRpc12Echo":
33 case "postJsonRpc12EchoNamed":
34 if (is_array($params)){
35 $results['result']=$params;
36 }else{
37 $results['result']=$params->message;
38 }
39 break;
40 default:
41 $results['result']="";
42 $results['error']=array();
43 $results['error']['code']=-32601;
44 $results['error']["message"]="The requested remote-procedure does not exist / is not available.";
45 header('HTTP/1.1 500 Server Error');
46 break;
47 }
48
49 $results['id'] = $req->id;
50
51 $encoded = $json->encode($results);
52
53 print $encoded;
54 ?>