PageRenderTime 323ms CodeModel.GetById 121ms app.highlight 1ms RepoModel.GetById 200ms app.codeStats 0ms

/examples/jsonrpc/public/services/phpolait/rpcproxy_call_method.php

http://pyjamas.googlecode.com/
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("&lt;&gt;"), $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?>