1

How do I get the token in this protected array

i only tried print_r(api_response->container) i already failed first here

here is the array

CyberSource\Model\FlexV1TokensPost200Response Object
(
    [container:protected] => Array
        (
            [keyId] => 07ULBKdmQGKMEtYIDIiazxlGHoA2Zllq
            [token] => xxxxxxxxxxxxxxxxxxxxxxx
            [maskedPan] => 424242XXXXXX4242
            [cardType] => 001
            [timestamp] => 1583678972960
            [signedFields] => token,cardType,maskedPan,timestamp
            [signature] => Oxw3kW4rbTXAbd832IMWyas7wQ5HvbS7cdhSYAgw5w3jGFTzKJSW7ki25ScjlpyOeri5dex1m+e9dxz7i1G0qhVMK8YiEDrTnsL8xitP0nhEFLO+eevM3dd+TmiAlB000Msnspts20wkurKdNWn+yiVn295vfbkhyBPYqxtTsZVcLHzNae7LmGbwsByxpf6dmVQY32h+PFOpTPRoH/QSKY7qnIb4baSO/4Wib/yQ8x7aHfQJ7JpdlTOm00YuGL3H3/saQkhABsbdF9MyL41GlgzBQVz/hrMxKxYU4gX8JHs3lTwkYmsibnJP6IIvvjDg0MAVlgTow/1sZRcj6a8HOA==
            [discoverableServices] => Array
                (
                )

        )

)
Mark Tyler
  • 11
  • 2
  • 2
    You cannot access private and protected properties and methods [outside a class](https://stackoverflow.com/questions/4361553/what-is-the-difference-between-public-private-and-protected/21902271#21902271). When you need something like that, your best bet is to check out the [class documentation](https://github.com/CyberSource/cybersource-rest-client-php/blob/master/lib/Model/FlexV1TokensPost200Response.php), which will tell you if there's a way to get a property (in this case, you're looking for a method that gets the token). – El_Vanja Mar 08 '20 at 15:01
  • 1
    Have you tried `api_response->getToken()` (from [source](https://github.com/CyberSource/cybersource-rest-client-php/blob/master/lib/Model/FlexV1TokensPost200Response.php)) – Nigel Ren Mar 08 '20 at 15:02
  • @NigelRen Thanks it works! I don't know why i get 2 response array it repeats the array that i posted but not the same token i only one last problem that i need to fix is to erase the duplicate of the array – Mark Tyler Mar 08 '20 at 15:12
  • @Nigel please progress this page to a system recognized resolution. – mickmackusa May 28 '23 at 12:13

0 Answers0