How to print status from this using PHP

63 Views Asked by At
stdClass Object
(
    [status] => success
    [message] => stdClass Object
        (
            [key] => stdClass Object
                (
                    [remoteJid] => [email protected]
                    [fromMe] => 1
                    [id] => BAE56CB55463AFE9
                )

            [message] => stdClass Object
                (
                    [documentMessage] => stdClass Object
                        (
                            [url] => some url
                            [mimetype] => application/pdf
                            [fileSha256] => hnB2OoCAoeO7lw6d6FFhankwG1UFHfnRCa+1mZisrfI=
                            [fileLength] => 4115
                            [mediaKey] => EfLEM03VY6ojspurx2b42H4ZQZh+8blcGZaa+mBiWhs=
                            [fileName] => To, abc.pdf
                            [fileEncSha256] => np/RpzMPZZVXzGJaMzu64R13vCAez4Pm10CTOK4+QmE=
                            [directPath] => /v/t62.711
                            [mediaKeyTimestamp] => 1686313196
                            [caption] => Thanks & Regards.
                        )

                )

            [messageTimestamp] => 1686313196
        )

)

Getting this output from curl which I have stored in $output.

I have tried: echo $output->status

1

There are 1 best solutions below

0
shubhada On

To access the status field from $output variable you can use the following PHP code:

$data = json_decode($output); // Decode the JSON response into a PHP object

$status = $data->status; // Access the "status" field

echo $status;