How To Access These StdClass Object Attributes?

Hi, good morning, I’m new here so I want to thanks for this forum and for your time. I’m using a PlayStation API, and I need to know, how to access some information contained in the stdClass Object. This is the information of the object using the print_r function:

PlayStation\Api\Game Object ( [titleId:PlayStation\Api\Game:private] => CUSA03842_00 [npCommunicationId:PlayStation\Api\Game:private] => NPWR10751_00 [game:PlayStation\Api\Game:private] => stdClass Object ( [npCommunicationId] => NPWR10751_00 [trophyTitleName] => Resident Evil 7: Biohazard [trophyTitleDetail] => Resident Evil 7: Biohazard [trophyTitleIconUrl] => http://trophy01.np.community.playstation.net/trophy/np/NPWR10751_00_0067A75086AF6955957B0F14790DB6DEDF01270DD1/0F061D22C9840D6AF8BF72E1520F986C13376604.PNG [trophyTitlePlatfrom] => PS4

How can I get the Platform attribute for example?, in the previous version of the API, I used something like this:

echo "Platform: ".$my_trophies->trophyTitles[$i]->trophyTitlePlatfrom."<br />";

But now, I can’t access those attributes, maybe because they are private, so, what can I do?

This is the PSN API site if you need to know about the API:

Thank you very much and have a nice day.

I highly recommend that you use a proper IDE (phpstorm, netbeans, etc), it will suggest all public properties and methods on objects so you dont have to dig around the source to figure it out.

Your other alternative is opening the file to see what publicly accessible stuff is there.

Thanks, but I’m using now Netbeans, and I can’t find those properties, I don’t know where to look for them, I use the find option and I can’t find something like [trophyTitlePlatfrom], so, I’m really lost.

The creator of the API uses funcions to gather some information contained in the Trophy.php or Game.php, but that information doesn’t include the attributes shown in the std Class Object, so, where that information of the object come from?

I hope you can help me with that, thank you.

Hi,
the method trophyInfo() of class Game should return the object with what you want. Try to print_r it’s result.

1 Like

Thank you very much Chack1172, that was the answer I was looking for, thank you very much.

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service