Debian Codegraph @

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