Read JSON return from cURL PHP [duplicate]

1

Only read a certain return value from cURL. When giving $arrData =json_decode($var); where $var is the return of curl_exec

I get:

    stdClass Object
    (
        [id] => PAY-A8XUTU4VSTE6
        [status] => WAITING
        [delayCapture] => 
        [amount] => stdClass Object
            (
                [total] => 120
                [fees] => 0
                [refunds] => 0
                [liquid] => 120
                [currency] => BRL
            )

        [installmentCount] => 1
        [fundingInstrument] => stdClass Object
            (
                [boleto] => stdClass Object
                    (
                        [expirationDate] => 2017-06-05
                        [lineCode] => 23793.39126 60000.105274 54001.747903 9 71810000000120
                        [instructionLines] => stdClass Object
                            (
                                [first] => Site
                            )

                    )

                [method] => BOLETO
            )

        [fees] => Array
            (
                [0] => stdClass Object
                    (
                        [type] => TRANSACTION
                        [amount] => 0
                    )

            )

        [events] => Array
            (
                [0] => stdClass Object
                    (
                        [type] => PAYMENT.CREATED
                        [createdAt] => 2017-05-26T19:25:34.913-03
                    )

                [1] => stdClass Object
                    (
                        [type] => PAYMENT.WAITING
                        [createdAt] => 2017-05-26T19:25:34.913-03
                    )

            )

        [receivers] => Array
            (
                [0] => stdClass Object
                    (
                        [moipAccount] => stdClass Object
                            (
                                [id] => MPA-**********
                                [login] => [email protected]
                                [fullname] => Fulano
                            )

                        [type] => PRIMARY
                        [amount] => stdClass Object
                            (
                                [total] => 120
                                [refunds] => 0
                            )

                    )

            )

        [_links] => stdClass Object
            (
                [self] => stdClass Object
                    (
                        [href] => https://sandbox.moip.com.br/v2/payments/PAY-A8XUTU4VSTE6
                    )

                [order] => stdClass Object
                    (
                        [href] => https://sandbox.moip.com.br/v2/orders/ORD-SLKVC9BB5OCT
                        [title] => ORD-SLKVC9BB5OCT
                    )

                [payBoleto] => stdClass Object
                    (
                        [redirectHref] => https://checkout-sandbox.moip.com.br/boleto/PAY-A8XUTU4VSTE6
                    )

            )

        [createdAt] => 2017-05-26T19:25:34.913-03
        [updatedAt] => 2017-05-26T19:25:34.913-03
    )

Now what exactly do I need is to know how to capture a certain value within that, as an example I tried:

echo $arrData["_links"][0]['payBoleto']['redirectHref'];

Returns me, Cannot use object of type stdClass as array

How exactly do you look for a value within this return?

    
asked by anonymous 27.05.2017 / 00:29

1 answer

2

Adding json_decode($var, true) to return as array.

Picking up the values: echo $arrData["_links"]['payBoleto']['redirectHref'];

    
27.05.2017 / 04:45