Open Argosth opened 10 months ago
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.
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?
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).
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?
Strange, seems fine to me. What PHP version are you running? For reference, I'm using PHP 8.2
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.
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?
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?
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.";
}
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?
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)
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:
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.
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 :)