Level 20
$rpcResult->id;
$rpcResult->result;
$rpcResult->jsonrpc;
or, if you will have to iterate on results than
foreach($rpcResult->result as $result)
{
...
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
After I've consumed a API, I've decoded the guzzle HTTP response, the object looks like:
{#2149 ▼
+"id": 0
+"jsonrpc": "2.0"
+"result": {#2146}
}
How can I get the content of result? It only shows this number, but how can I get deeper access into it?
Guzzle code:
try{
$response = $this->client->request('POST', '/json_api', [
'json' => [
'jsonrpc' => '2.0',
'method' => $method,
'params' => $params,
]
]);
$rpcResult = json_decode($response->getBody());
}
catch(ClientException | ServerException $e){
Log:error("error catch");
}
return $rpcResult->result;
Please or to participate in this conversation.