PageRenderTime 28ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/examples/dynamictable/public/phpolait/rpcproxy_call_method.php

http://pyjamas.googlecode.com/
PHP | 33 lines | 16 code | 6 blank | 11 comment | 3 complexity | 7c7a9d83539aff6ae09ed39556f93f91 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * Internal code for the JSONRpcProxy::__call function
  4. * This _extremely_ annoying approach is necessitated to have PHP 4 and PHP 5 compatibility with the same code-base.
  5. * I SINCERELY hope it works!
  6. */
  7. $json = new PHPJsonWrapper($this->jsonlib);
  8. $postData = array (
  9. "id"=>"remoteRequest",
  10. "method"=>$method,
  11. "params"=>$args
  12. );
  13. $postData = $json->encode($postData);
  14. /* Make a HTTP Post Request */
  15. $jsonresult = $this->httpWrap->post($this->url, $postData);
  16. /* Some debugging code
  17. echo "<b>JSONRpcProxy::$method received:</b><br/><pre>";
  18. echo str_replace(array("<",">"),array("&lt;&gt;"), $jsonresult);
  19. echo "</pre><hr>";
  20. */
  21. $result = $json->decode($jsonresult);
  22. if ((is_object($result)) && ($result->id=="remoteRequest")) {
  23. $return = array($result->result, $result->error);
  24. } else {
  25. $return = array(null, "JSON-RPC call failed.", $jsonresult);
  26. }
  27. ?>