-
Notifications
You must be signed in to change notification settings - Fork 73
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
Search for a specific game of a user by npCommunicationId() instead of the name #254
Comments
I don't think this tool has an iterator for exact match. You could probably edit the current iterator, but you will loose the current behavior then. psn-php/src/Iterator/Filter/TrophyTitle/TrophyTitleNameFilter.php Lines 15 to 18 in 5d9a357
I think changing the return to something like this should work for you: Please note that this will only return exact matches now. So if a game have the name "Resident Evil™" so will you not find it by searching for "Resident Evil". It's also quite common for some games to have the name trophies in it, like "Resident Evil Trophies", which will also not be found if you search for "Resident Evil". And as I said, this change will remove the current behavior. If you want both you have the create a new iterator and function, maybe "withExactName()" or something like that. It might just be easier to change your own code to loop through the results for what you're looking for. It won't probably be that many games.
Again, you will still have to look out for ™ and Trophies and other strange things in names. |
Thank you very much, I will look for other options too, ty mate :) |
One more question @Ragowit, would you know how to determine the size or the games that a player has from $user->trophyTitles() without having to loop through the entire foreach? I need to know the number of games a player has, and the only way I have found is by iterating through the entire loop and adding it to a counter. |
The API returns the total number of games. I'm uncertain if this number includes hidden games or not. I'm also uncertain from the top of my head which function it was you should use, it's one of these two: |
@Ragowit I tried the two options but nothing, and I'm looking into TrophyTitles Factory and there is no an option to determine the object size I think. |
I was looking at https://github.com/Tustin/psn-php/blob/master/src/Iterator/TrophyTitlesIterator.php which inherits from https://github.com/Tustin/psn-php/blob/master/src/Iterator/AbstractApiIterator.php that has count() and getTotalResults(). Should be there if I understand the code right. psn-php/src/Iterator/AbstractApiIterator.php Lines 39 to 53 in 5d9a357
|
Hey @Ragowit do you know if there is a way to find For example: But to fetch game details (such as media) I need |
No, I don't know of such a way. |
Hello, I would like to know if the API has the possibility to search for a specific game of a user since the given method of the API by name is not exact when searching for a game and may return several:
I want it to return only the game Resident Evil, and not all that contain Resident Evil in their name, any ideas or solutions?
@Ragowit any idea about this?
Thank you very much.
The text was updated successfully, but these errors were encountered: