PHP code example of muvon / kiss-json-rpc

1. Go to this page and download the library: Download muvon/kiss-json-rpc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

muvon / kiss-json-rpc example snippets


use Muvon\KISS\JsonRpc;
$rpc = JsonRpc::creete(
  'http://rpc-server.ip.or.host',
  'username',
  'password'
);

// Call one method
[$err, $result] = $rpc->call('method', [1, 2, 3]);

// Call several methods asycn
$multi = [
  ['method1', ['param1', 'param2']],
  ['method2', ['param1', 'param2']],
];
[$err, $results] = $rpc->callMulti($multi);

// Call method using magic
[$err, $result] = $rpc->method_name(['param1', 'param2']);

use Muvon\KISS\JsonRpc;

$rpc = JsonRpc::create($url);

[$err, $result] = $rpc->call('getblockcount');

[$err, $results] = $rpc->callMulti(
  ['getblockhash', [1]],
  ['getblockhash', [2]],
);

// var_dump($results)
// [ array of response1, array of response2 ]

$rpc->getblockhash(1);