Tustin / psn-php

A PHP wrapper for the PSN API
https://tustin.dev/psn-php/
MIT License
358 stars 74 forks source link

Why it is not possible to get more trophy info with one request? #227

Closed Sakreetos closed 2 years ago

Sakreetos commented 2 years ago

Hello.

I wonder why it is impossible to get full trophy info(usual info + earned status)?

Is there any workaround?

Here is my code:

    foreach ($client->users()->search('Sakreetos') as $user) {
        $titles = $user->trophyTitles();
        foreach ($titles as $title) {
            if ($title->hasTrophies()) {
                $trophyGroups = $title->trophyGroups();
                foreach ($trophyGroups as $trophyGroup) {
                    foreach ($trophyGroup->trophies() as $trophy) {
                        $trophyEarned = $trophy->earned();
                        $trophyName = $trophy->name();

                    }
                }
            }
        }
    }
Reuns commented 2 years ago

Hello, You have to pay attention to where you're getting your informations from :

To get trophy informations (name, desc, ...) $users->trophyTitles()

To get user's trophy progression (earned, ...) $users->gameList()

Why ? Because it is how Sony made it.