PHP code example of jaczkog / json-rpc

1. Go to this page and download the library: Download jaczkog/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/ */

    

jaczkog / json-rpc example snippets


use JsonRpc\JsonRpcClient;

$jsonRpcClient = new JsonRpcClient('rpc-server:8080', JsonRpcClient::VERSION_1);
$response      = $jsonRpcClient->sendRequest('method_name', ['param1' => 1, 'param2' => true]);

if ($response->isSuccess()) {
    echo $response->result;
} else {
    echo sprintf('ERROR: %s (%d)', $response->error->message, $response->error->code);
}