/examples/dynamictable/public/phpolait/rpcproxy_call_method.php
PHP | 33 lines | 16 code | 6 blank | 11 comment | 3 complexity | 7c7a9d83539aff6ae09ed39556f93f91 MD5 | raw file
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 9 $postData = array ( 10 "id"=>"remoteRequest", 11 "method"=>$method, 12 "params"=>$args 13 ); 14 15 $postData = $json->encode($postData); 16 17 /* Make a HTTP Post Request */ 18 $jsonresult = $this->httpWrap->post($this->url, $postData); 19 20 /* Some debugging code 21 echo "<b>JSONRpcProxy::$method received:</b><br/><pre>"; 22 echo str_replace(array("<",">"),array("<>"), $jsonresult); 23 echo "</pre><hr>"; 24 */ 25 26 $result = $json->decode($jsonresult); 27 28 if ((is_object($result)) && ($result->id=="remoteRequest")) { 29 $return = array($result->result, $result->error); 30 } else { 31 $return = array(null, "JSON-RPC call failed.", $jsonresult); 32 } 33?>