How to read every field of a web response of messagebird

129 Views Asked by At

Here is the response i receive after send every successful sms. Output of php code print_r($MessageResult); is give below.

    MessageBird\Objects\Message Object
(
    [id:protected] => op34f300d57a4217xc9d48be7b890fd4
    [href:protected] => https://rest.messagebird.com/messages/ae3956ccd57af2f7939d48be7b891qd4
    [type] => sms
    [originator] => +12223334444
    [body] => sms text body is here
    [typeDetails] => stdClass Object
        (
        )

    [datacoding] => plain
    [mclass] => 1
    [scheduledDatetime] => 
    [createdDatetime:protected] => 2021-06-25T18:55:38+00:00
    [recipients] => stdClass Object
        (
            [totalCount] => 1
            [totalDeliveryFailedCount] => 0
            [items] => Array
                (
                    [0] => MessageBird\Objects\Recipient Object
                        (
                            [recipient] => 19998886666
                            [status] => sent
                            [statusDatetime] => 2021-06-25T18:55:38+00:00
                        )
                )
        )
    [reportUrl] => 
)

I get correct value for php code

echo $MessageResult->body  

But I have tried by php code echo $MessageResult->id; and get error: Fatal error: Uncaught Error: Cannot access protected property MessageBird\Objects\Message::$id

My question is, How do i read id value? (which is here op34f300d57a4217xc9d48be7b890fd4)

0

There are 0 best solutions below