/public/javascripts/dojo/dojox/rpc/tests/resources/jsonRpc10.php

http://enginey.googlecode.com/ · PHP · 47 lines · 24 code · 12 blank · 11 comment · 0 complexity · 67afe05cdd9af26db5025dfd6a57a53a MD5 · raw file

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