1. Go to this page and download the library: Download moaction/jsonrpc-common 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/ */
moaction / jsonrpc-common example snippets
$request = new \Moaction\Jsonrpc\Common\Request
$request->setId(1);
$request->setMethod('getUserData');
$request->setParams(array('userId' => 4, 'field' => 'email'));
// here you get valid jsonrpc 2.0 request object ready for json_encode
// \InvalidArgumentException can be thrown when Request object is misconfigured (method is not set).
$data = $request->toArray();
// decoded array with jsonrpc 2.0 response
$data = array(
'id' => 1,
'result' => array(
'email' => '[email protected]',
),
);
// \Moaction\Jsonrpc\Common\Exception can be thrown when object is not valid jsonrpc response
$response = new \Moaction\Jsonrpc\Common\Response::fromArray($data);