Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to a member function getUser() on null if try to get trophies #266

Open
dark-cms opened this issue Jan 5, 2025 · 1 comment
Open

Comments

@dark-cms
Copy link

dark-cms commented Jan 5, 2025

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)

@Tustin
Copy link
Owner

Tustin commented Jan 6, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants