PHP code example of etk-pl / json-rpc
1. Go to this page and download the library: Download etk-pl/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/ */
etk-pl / json-rpc example snippets
use JsonRpc\Client;
use JsonRpc\Request;
$client = new Client('http://localhost:8080/');
$response = $client->send(new Request([
'resource' => 'Test',
'method' => 'echo',
'params' => ['param' => 'value']
]));
if($error = $response->getError()) {
die("Got error: " . $error['message']);
}
$result = $response->getResult();
var_dump($result);
use JsonRpc\ApiClient;
$client = new ApiClient('http://localhost:8080/');
try{
$result = $client->Test->echo(['param' => 'value']);
} catch(\Exception $e) {
die("Got error: " . $error['message']);
}
var_dump($result);