Exemple #1
0
<pre>
<?php 
/**
 * Available methods:
 * - notify
 * - echo
 * - math.sum
 * - math2.special.substract
 */
require_once __DIR__ . '/../lib/Client.php';
// Instantiate and call
$client = new Lightbulb\Json\Rpc2\Client('http://github.loc/JSONRpc2/tests/serverTest.php');
//$client->debug = true;
echo 'call $client->notify();<br />';
var_dump($client->notify());
echo '<hr />';
echo 'call $client->echo("something");<br />';
var_dump($client->echo('something'));
echo '<hr />';
echo 'call $client->math->sum(25, 30, 45);<br />';
var_dump($client->math->sum(25, 30, 45));
echo '<hr />';
echo 'call $client->math2->special->substract(25, 5, 10);<br />';
var_dump($client->math2->special->substract(25, 5, 10));
echo '<hr />';
echo 'call $client->__call("math2.special.substract", array(25, 5, 10));<br />';
var_dump($client->__call('math2.special.substract', array(25, 5, 10)));
Exemple #2
0
 /**
  * Handles generic send of the payload
  */
 public function handleSendJson($method)
 {
     // Prepare the request
     $args = $this->_mapJson($_POST, $_POST);
     // Showtime!
     $client = new \Lightbulb\Json\Rpc2\Client($this->endpoint);
     $client->_debug();
     $return = $client->__call($method, $args);
     // Assign into the template
     $this->template->jsonRequest = \Lightbulb\Json\Rpc2\Client::formatJson($client->_getRequest());
     $this->template->jsonResponse = \Lightbulb\Json\Rpc2\Client::formatJson($client->_getResponse());
     $this->template->parsedResponse = $return;
 }