I'm trying to form a JSON-RPC request in the following format:
{
"jsonrpc": "2.0",
"id": 1,
"method": "call.search",
"params": [
"acc",
srh: {
"user"
}
]
}
But I'm having difficulty creating the request with the correct format using PHP. My code looks like this:
function prepareRequest($procedure, array $params = array())
{
$payload = array(
'jsonrpc' => '2.0',
'method' => $procedure,
'id' => mt_rand()
);
if (! empty($params)) {
$payload['params'] = $params;
}
return $payload;
}
$req = json_encode('9999');
$request = prepareRequest('call.search', array('acc','srh' => $req));
$json = json_encode($request);
echo $json;
My result so far looks like this:
{
"jsonrpc":"2.0",
"method":"call.search",
"id":1339580122,
"params":{
"0":"acc",
"srh":"\"user\""
}
}