-
Notifications
You must be signed in to change notification settings - Fork 74
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
How do I retrieve the trophy list for a specific game? #264
Comments
Yeah, the documentation is missing quite a bit. $titles = $user->trophyTitles()->withName('Red Dead Redemption'); This line of code is looking for games with the name "Red Dead Redemption" for this current user. It will return all games found, as you noticed. To get the trophy list, you have to do something like this: foreach ($user->trophyTitles()->withName('Red Dead Redemption') as $trophyTitle) {
foreach ($client->trophies($trophyTitle->npCommunicationId(), $trophyTitle->serviceName())->trophyGroups() as $trophyGroup) {
// Handle "group" data here
foreach ($trophyGroup->trophies() as $trophy) {
// Handle "trophy" data here. This is only game trophy data, not user earned trophy data.
}
}
foreach ($trophyTitle->trophyGroups() as $trophyGroup) {
foreach ($trophyGroup->trophies() as $trophy) {
// This has trophy earned data for current user.
}
}
} |
But what if I want to recover a game that this user has NEVER played, can I do so? However I'm trying to get the main trophy data, and when I call echo $trophy->name() .' - '. $trophy->detail().' - '. $trophy->type() .' <br>'. $trophy->iconUrl(). '<br>';
if I remove type(), the other values are printed correctly instead also for greater precision, for example when I search for games such as:
is it possible to search it by title ID?
In the PlayStation-Trophies API it is possible with:
|
Simple answer, no. The $client->trophies() function requires you to send in "np communication id" (NPWR..._00), which is only obtained by looking through users gamelist. So unless you somehow already have a huge list of "np communication id"s from somewhere (I don't), the only option is to go through a users game list. Lines 203 to 213 in b4ecb23
Regarding $trophy->type(), I don't know from your code if you're inside $user->trophyTitles()->trophyGroups()->trophies() or $client->trophies()->trophyGroups()->trophies(). Please remember that trophy-data you get is different from which one you're calling from. Look at these docs as an example: However, trophy type should be in both. Can you try EDIT: New questions were added to post while I was writing. There's this from the $user: Lines 75 to 94 in b4ecb23
I haven't used it myself though and don't know much about it. Don't know if it can return an answer about games that the user doesn't have. |
ok it works it was my mistake. for the second question, that of getting the data of the games using their title ID or communication id $users = $user->titleIdToCommunicationId('PPSA01284_00'); //returnal I receive as output
* Gets a trophy title from the API using a communication id (NPWRxxxxx_00). so i pass communication id inside trophies, But in inside $client->trophies as $serviceName of trophies what do I put? $npCommunicationId = $user->titleIdToCommunicationId('PPSA01284_00');
$trophyGroups = $client->trophies($npCommunicationId)->trophyGroups();
foreach ($trophyGroups as $trophyGroup) {
foreach ($trophyGroup->trophies() as $trophy) {
echo $trophy->name();
}
} |
In my case, I tried I also tried the command on powershell and nothing.... Invoke-RestMethod -Uri "https://m.np.playstation.com/api/trophy/v1/npCommunicationIds/PPSA08709_00/trophyGroups/all/trophies?npServiceName=trophy" -Authentication Bearer -Token $token | ConvertTo-Json -Depth 3 So there's really no way to retrieve the trophy list for the games I don't have in my profile.... List of trophies in Italian language cannot be found, so it is also difficult to make a scrape... |
It is not clear to me how I can retrieve the trophy list of a game.
In the documentation under ‘trophy titles’ I have:
so, if i write:
I would expect to find a list of the game Red Dead Redemption, no?
Instead, I receive as output the games that have Red Dead Redemption as their name, namely:
using:
I want to receive the list of Red Dead Redemption trophies, but in the documentation I can't figure out how to do it....
The text was updated successfully, but these errors were encountered: