Call to a member function getUser() on null if try to get trophies
Version: 5.0.0.x-dev
I'm getting a bit desperate at the moment.
No matter what I try, I can't get my own trophies because the code exits at a certain point.
Breakdown of my Code: I have completely reduced the code for the purpose of simplicity
foreach ($this->me->trophyTitles() as $game) {
if ($game->hasTrophies()) {
foreach ($game->trophyGroups() as $trophyGroup) {
foreach ($trophyGroup->trophies() as $trophy) {
}
}
}
The Code throws an Exception:
Call to a member function getUser() on null
(https://github.com/Tustin/psn-php/blob/9a939e55b399d956319f8d4125f517ce4747da08/src/Iterator/TrophyGroupsIterator.php#L23C1-L29C15)
if ($this->title instanceof UserTrophyTitle) {
$results = $this->get(
'trophy/v1/users/' . $this->title->getFactory()->getUser()->accountId() . '/npCommunicationIds/' . $this->title->npCommunicationId() . '/trophyGroups',
[
'npServiceName' => $this->title->serviceName()
]
);
When I test what $this->title->getFactory() returns, it is always null
Unfortunately, other issue entries have not helped me and the instructions are a bit old, so I hope someone can help me. Basically, the endpoints fit to retrieve all my trophies (at least compared to another system)
Have you tried this on the 4.0.0 version? I'm still in the process of working on the 5.0.0 version so it's not quite stable and probably has issues like this.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.