Open Argosth opened 5 years ago
I think I ran into the same issue as well. I will try to investigate in the coming days/weekend as well. I'll share what I've found when I have something to share. Maybe a bit off topic, as this repo is a php wrapper for the sony playstation api, can I read that API somewhere? Probably you need to have a dev account or something. It would make debugging a bit easier, as it gets easier to check the typing of this wrapper against the API documentation. I could not find the documentation anywhere myself.
I think I ran into the same issue as well. I will try to investigate in the coming days/weekend as well. I'll share what I've found when I have something to share. Maybe a bit off topic, as this repo is a php wrapper for the sony playstation api, can I read that API somewhere? Probably you need to have a dev account or something. It would make debugging a bit easier, as it gets easier to check the typing of this wrapper against the API documentation. I could not find the documentation anywhere myself.
Unfortunately there is (currently) no public API. This library uses the "private" API that Sony has in place for its own apps and such, and therefore there is no documentation.
@jbdabes Thanks for the reply. Will do it the old fashioned way then :).
My question is, why is the comparedUser
property giving errors?
I also realise that using other options, I get 36 results, so I think that's the maximum amount of the array we can get.
I hope you masters can find a solution. Thank you.
Hi, good morning, I found this problem when I use the API.
I got the token I can consult almost all the information, when I put the next code:
$games = $client->user('Argosth')->games();
I got this result:
Resident Evil 7: Biohazard has 38 trophies Notice: Undefined property: stdClass::$comparedUser in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 101
Notice: Trying to get property 'earned' of non-object in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 101
Fatal error: Uncaught TypeError: Return value of PlayStation\Api\Trophy::earned() must be of the type bool, null returned in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php:102 Stack trace: #0 C:\xampp\htdocs\Argosth\admin\psn.php(160): PlayStation\Api\Trophy->earned() #1 {main} thrown in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 102
Now, when I use the Tustin Account:
$games = $client->user('tustin25')->games();
I get more results:
Call of Duty®: Black Ops 4 has 53 trophies [bronze] My Home is the Arena - In IX, survive to Round 20 without opening a gate (earn rate - 1.20%) [silver] Venerated Warrior - In IX, defeat the most venerated opponent (earn rate - 1.20%) [bronze] Skilled Adversary - In IX have a Challenge banner with all 9 medallions (earn rate - 2.30%) [bronze] The Slaughterhouse - In IX, dismember 13 limbs in a single game while in The Pit (earn rate - 12.30%) [bronze] Gong like the Wind - In IX, defeat all 8 challengers summoned by a gong within 5 minutes (earn rat
But in the final result, there is the next error:
Notice: Undefined property: stdClass::$comparedUser in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 101
Notice: Trying to get property 'earned' of non-object in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 101
Fatal error: Uncaught TypeError: Return value of PlayStation\Api\Trophy::earned() must be of the type bool, null returned in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php:102 Stack trace: #0 C:\xampp\htdocs\Argosth\admin\psn.php(160): PlayStation\Api\Trophy->earned() #1 {main} thrown in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 102
So, I don't know why some users have more results and other less, but the same error at the end.
I hope you can help me, thank you and have a nice day.
Can you share your code with me so I can test this for myself? Using the code you provided works fine on my dev environment (PHP 7.3).
Alright, so with some digging I've discovered this is limited to specific games (in the given example, it's The Evil Within 2). I'm not sure why but it doesn't seem to return the comparing user. I've added a temp fix which for now will return false for any games that does not pass this data back and have notified Tustin about looking into this specific issue a little deeper.
That was so weird too, the thing is, I have played The Evil With In 2, but I don't have the game or trophies loaded to psn, I have the Evil Within the first delivered complete 100%.
How can I apply the fix JB?
Thank you.
Obtener Outlook para Androidhttps://aka.ms/ghei36
From: JB notifications@github.com Sent: Friday, May 24, 2019 7:30:52 AM To: Tustin/psn-php Cc: Argosth; Author Subject: Re: [Tustin/psn-php] Notice: Trying to get property 'earned' of non-object in (#93)
Alright, so with some digging I've discovered this is limited to specific games (in the given example, it's The Evil Within 2). I'm not sure why but it doesn't seem to return the comparing user. I've added a temp fix which for now will return false for any games that does not pass this data back and have notified Tustin about looking into this specific issue a little deeper.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Tustin/psn-php/issues/93?email_source=notifications&email_token=AJNTVZ3YEPCEL65TC2QEUUDPW5VPZA5CNFSM4HOTMCC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWED7UY#issuecomment-495468499, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJNTVZ2DDZ4A2ZXPOTXCLDLPW5VPZANCNFSM4HOTMCCQ.
That was so weird too, the thing is, I have played The Evil With In 2, but I don't have the game or trophies loaded to psn, I have the Evil Within the first delivered complete 100%. How can I apply the fix JB? Thank you.
Best way right now would be to update your composer.json file to install tustin/psn-php pulling from dev-master:
"require": {
"tustin/psn-php": "dev-master"
},
Then just composer update
.
I'll tag a new release once we've gotten a few other things fixed - when this is done I'd recommend using ^2.1
instead of dev-master
.
You may need to run composer clearcache
before it finds the latest commit.
Hi again, I've been doing some test to see which functions are not working properly, and at this moment, this is my experience:
game.php errors:
trophyGroup errors:
Different Results dependind of the user:
I don't really understand why some users retrieve more results than others.
Thank you and have a nice day.
@Argosth I've bumped into these errors as well. Currently working on a PR to change the game class a bit. I hope to have a pull request by tomorrow.
In my PR i'll be solely focussing on the errors you describe in game.php
. I'll pull some methods apart as in some cases they do multiple things. Getting a boolean as result in one scenario and an object in another scenario can be a bit unpredictable.
@mrcrazylee Appreciate it. I've been trying to get back to working on this library and realized I did some pretty dumb things when I rewrote this lol. I was trying to keep it as simple as possible by having some methods do multiple things which isn't really a good idea.
As for this problem, if that PR doesn't solve it I can take a look at this. I don't remember ever encountering a problem like this so it could be something new that Sony did in the API that I haven't accounted for yet.
Sure thing. First things first, I love that you have taken the time to setup this library! And I am by no means a pro at this, I am just trying to contribute where I can. As I am just a frontender by nature, please also look at my PR's with a sceptical eye. Believe you me, a couple of years ago I would probably have done the same. Again credits for putting your time and effort into this.
I can definitely see Sony changing its API. As you mentioned before, it is a private API. I think I have the bugs in the game.php
file covered. Just need to do some additional testing to see how it is implemented in the other files of this library. Locally I think I've got it working, but I just want to be sure :)
When @Tustin finishes up writing tests it should make spotting issues like this a lot easier!
@Argosth The problems you encounter in Game.php
should be solved with this PR: https://github.com/Tustin/psn-php/pull/94
@mrcrazylee Thank you very much, I've applied the modifications, it seems that now there are less errors.
I still have the problem of only 15 games in total, and "The Evil Within 2" a game that I don't have but maybe is a problem of my profile perhaps.
Other errors I found are located in Trophy.php and TrophyGroup.php, related with the function lastEarnedDate() and earnedDate() for example:
Notice: Undefined property: stdClass::$comparedUser in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\TrophyGroup.php on line 92
Notice: Trying to get property 'lastUpdateDate' of non-object in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\TrophyGroup.php on line 92
Thank you very much for your effort and have a nice day.
Good morning, I want to say that I'm willing to help in this protect, but the thing is, I'm not a PHP expert, but I want to help, is there a way in what I can be useful?
Thank you.
Getting this error as well. Does the upcoming 2.2 or the PR solve the problem? And if so, when will it become available?
I don't know much about this library or PSN, but I got it working with this fix:
in src/Api/Trophy.php
, there is function like this:
public function earned() : bool
{
return $this->comparing() ?
$this->trophy->comparedUser->earned :
$this->trophy->fromUser->earned;
}
I replaced it with this function:
public function earned() : bool
{
if($this->comparing()) {
if(isset($this->trophy->comparedUser)) {
return $this->trophy->comparedUser->earned;
}
}
return isset($this->trophy->fromUser) ? $this->trophy->fromUser->earned : false;
}
So better checking if comparedUser
is set or not
This was solved with 6a608a3213fe23daa486b9afea1f9016f137766a, correct?
Hi, good morning, I found this problem when I use the API.
I got the token I can consult almost all the information, when I put the next code:
$games = $client->user('Argosth')->games();
I got this result:
Resident Evil 7: Biohazard has 38 trophies Notice: Undefined property: stdClass::$comparedUser in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 101
Notice: Trying to get property 'earned' of non-object in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 101
Fatal error: Uncaught TypeError: Return value of PlayStation\Api\Trophy::earned() must be of the type bool, null returned in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php:102 Stack trace: #0 C:\xampp\htdocs\Argosth\admin\psn.php(160): PlayStation\Api\Trophy->earned() #1 {main} thrown in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 102
Now, when I use the Tustin Account:
$games = $client->user('tustin25')->games();
I get more results:
Call of Duty®: Black Ops 4 has 53 trophies [bronze] My Home is the Arena - In IX, survive to Round 20 without opening a gate (earn rate - 1.20%) [silver] Venerated Warrior - In IX, defeat the most venerated opponent (earn rate - 1.20%) [bronze] Skilled Adversary - In IX have a Challenge banner with all 9 medallions (earn rate - 2.30%) [bronze] The Slaughterhouse - In IX, dismember 13 limbs in a single game while in The Pit (earn rate - 12.30%) [bronze] Gong like the Wind - In IX, defeat all 8 challengers summoned by a gong within 5 minutes (earn rat
But in the final result, there is the next error:
Notice: Undefined property: stdClass::$comparedUser in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 101
Notice: Trying to get property 'earned' of non-object in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 101
Fatal error: Uncaught TypeError: Return value of PlayStation\Api\Trophy::earned() must be of the type bool, null returned in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php:102 Stack trace: #0 C:\xampp\htdocs\Argosth\admin\psn.php(160): PlayStation\Api\Trophy->earned() #1 {main} thrown in C:\xampp\htdocs\Argosth\vendor\tustin\psn-php\src\Api\Trophy.php on line 102
So, I don't know why some users have more results and other less, but the same error at the end.
I hope you can help me, thank you and have a nice day.