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

Trophy Earned Rate Not Working Anymore? #253

Open
Argosth opened this issue Oct 24, 2023 · 12 comments
Open

Trophy Earned Rate Not Working Anymore? #253

Argosth opened this issue Oct 24, 2023 · 12 comments

Comments

@Argosth
Copy link

Argosth commented Oct 24, 2023

I was using earnedRate() function yesterday and was working fine, but now, I get 0 for every trophy linked to a player, do you know if this a temporary issue or now is blocked by the PSN Api?

Thank you :)

@Ragowit
Copy link
Collaborator

Ragowit commented Oct 24, 2023

I noticed that on my PS5 console around the time you wrote this issue so was it really slow on loading trophies. Might have been a Sony hiccup.

@Argosth
Copy link
Author

Argosth commented Oct 24, 2023

I noticed that on my PS5 console around the time you wrote this issue so was it really slow on loading trophies. Might have been a Sony hiccup.

Still not working but the API is too slow at this moment, so maybe they will fix this soon, or what do you think?

@Ragowit
Copy link
Collaborator

Ragowit commented Oct 24, 2023

Honestly, I don't know. And you're sure you haven't made any changes to your code?

I have a strange bug that this tool only grabs the first data I ask for about a trophy linked to the player. See #250 for it (and my workaround).

@Argosth
Copy link
Author

Argosth commented Oct 25, 2023

Honestly, I don't know. And you're sure you haven't made any changes to your code?

I have a strange bug that this tool only grabs the first data I ask for about a trophy linked to the player. See #250 for it (and my workaround).

This is my code:

$user = $client->users()->find($userAccount);
foreach ($user->trophyTitles() as $game)
foreach ($game->trophyGroups() as $trophyGroup) {
foreach ($trophyGroup->trophies() as $trophy) {
$trophyDate = (clone $trophy)->earnedDateTime();
$trophyRate = $trophy->earnedRate();`

I used your solution but still not working :(

I tried your solution: $trophyDate = (clone $trophy)->earnedDateTime(); but nothing, and I realized that earnedDateTime is not working too, so both returns 0. Any ideas?

@Ragowit
Copy link
Collaborator

Ragowit commented Oct 25, 2023

Strange, seems fine to me. What PHP version are you running? For reference, I'm using PHP 8.2

@Argosth
Copy link
Author

Argosth commented Oct 25, 2023

Strange, seems fine to me. What PHP version are you running? For reference, I'm using PHP 8.2

My version is 8.2.4, and the thing is that two days ago was working fine. Did you try to update a user PSN Trophies? When I do that, always retrieve 0 from earnedDateTime and earnedRate, should I put clone in both variables?

Ty Ragowit.

@Ragowit
Copy link
Collaborator

Ragowit commented Oct 25, 2023

My site https://psn100.net updates just fine.

No, clone on both shouldn't be needed. Have you tried to update your npsso on the account your using with the script?

@Argosth
Copy link
Author

Argosth commented Oct 25, 2023

My site https://psn100.net updates just fine.

No, clone on both shouldn't be needed. Have you tried to update your npsso on the account your using with the script?

This is the method I'm using right now:

/* Link Login PSN: https://www.playstation.com/ */
/* Get NPSSO: https://ca.account.sony.com/api/v1/ssocookie */

$npsso = $DatabaseOperations->getNpsso(); /* From My Database */
define('NPSSO', $npsso['npsso']);
    
/* PSN Tustin Declarations */
use Tustin\PlayStation\Client;
$client = new Client();
$client->loginWithNpsso(NPSSO);
$refreshToken = $client->getRefreshToken()->getToken(); // Save this code somewhere (database, file, cache) and use this for future logins
/* PSN Tustin Declarations */

When I try to use the verbose method, it returns this errors from navigator console:

Error with Permissions-Policy header: Unrecognized feature: 'document-domain'.
POST https://auth.api.sonyentertainmentnetwork.com/2.0/ssocookie 403 (Forbidden)

Then I log-out my current psn session and seems to be working with the verbose method, but with some erros.

And if I try to use the $client->login('npsso'); Api returns that the method login doesn't exists, do you see something wrong?

@Ragowit
Copy link
Collaborator

Ragowit commented Oct 25, 2023

Seems good, here's my login code for reference:

try {
    $client = new Client();
    $npsso = GetNpssoFromDatabase();
    $client->loginWithNpsso($npsso);
} catch (Exception $e) {
    echo "Something went wrong with login.";
}

@Argosth
Copy link
Author

Argosth commented Oct 26, 2023

Seems good, here's my login code for reference:

try {
    $client = new Client();
    $npsso = GetNpssoFromDatabase();
    $client->loginWithNpsso($npsso);
} catch (Exception $e) {
    echo "Something went wrong with login.";
}

Hello Ragowit, now, with the next code, I'm getting trophy rate correctly, but no the earnedDateTime()

`require_once 'includes/psn.php';

$user = $client->users()->find('9150243351170436908');
foreach ($user->trophyTitles() as $game) {
    $platforms = $game->platform();
    foreach ($game->trophyGroups() as $trophyGroup) {
        foreach ($trophyGroup->trophies() as $trophy) {
            $trophyRate = $trophy->earnedRate(); 
            $trophyDate = (clone $trophy)->earnedDateTime();
            $trophyType = $trophy->type();
            
            echo("<br />Rate: ".$trophyRate."<br />");
            echo("<br />Date: ".$trophyDate."<br />");
            echo("<br />Trphy Type: ".$trophyType."<br />");
            echo("<br />Platform: " . implode(", ", $platforms) . "<br />");
        }
    }
}`

Trophy Platform, type and rate are ok, but date is returning null, any ideas?

@Ragowit
Copy link
Collaborator

Ragowit commented Oct 27, 2023

The date can be null, mostly common in the PS3 era. Are you sure that the date in this case isn't suppose to be null? Have you compared that user with other sites? (I don't know who 9150243351170436908 is)

@Argosth
Copy link
Author

Argosth commented Oct 28, 2023

The date can be null, mostly common in the PS3 era. Are you sure that the date in this case isn't suppose to be null? Have you compared that user with other sites? (I don't know who 9150243351170436908 is)

Ok, found the problem and the solution:

  • The account I was using is an old account and maybe it doesn't have trophy date, so I test with another account and realized that, if you separate earnedRate with earnedDateTime in different blocks, will works, but, also earnedDateTime must be the first in the line just after the new block, for example:
foreach ($trophyGroup->trophies() as $trophy) {
   $trophyRate = $trophy->earnedRate(); /* Separated. */
      if ($trophy->earned()) {
         $trophyDate = $trophy->earnedDateTime(); /* In the first Line after If. */
         $trophyProgress = $trophy->progress();
         $trophyName = $trophy->name();
        $trophyType = $trophy->type();
      }
}

If you put earnedDateTime() just after the if, it works fine, but if you set that line after progress, name or another one, it will return null, seems weird, I also try to use clone but nothing, so that's it, earnedRate before (earned()) and earnedDateTime just after the conditional.

Thank you Ragowit, thanks to you I found the strange solution hehehe.

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