question

jzlnikola avatar image
jzlnikola asked

How to enable players to "like" UGC items?

In our case UGC items are levels created by players. We want other player's to be able to "like" them. That means that we need to find a way to:

  1. Increment "likes" count on UGC item(level), after a player "likes" it.

  2. Check if player already liked that level(to prevent him from incrementing like count more than once)

  3. Get the list of all levels player liked.

How can we do this by using Playfab?

CloudScriptPlayer Inventory
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Neils Shi avatar image
Neils Shi answered

In fact, PlayFab has provided a rating system which can help you evaluate the UGC items, please refer to Adding ratings to your content - PlayFab | Microsoft Learn for more details. In your case, you want to implement the "Like" feature for the UGC items, as a workaround, you can implement this feature based on the rating system we provide. When the players want to like an item, they can call the API ReviewItem to create a review for this item, and after that they can call API GetItemReviewSummary to see how many people like the item by checking the “ReviewsCount”. Please note that the summary ratings data is cached with update data coming within 15 minutes. And as Adding ratings to your content - PlayFab | Microsoft Learn mentions that ratings and reviews are attached to the player calling the API and only a single review per player can be associated with an item, so you don't have to worry about players liking the same item multiple times. And if the players want to retrieve the list of items they liked previously, they can call the API UpdateUserData to save the item id of the liked items to the user data after liking the item, after that they can call the API GetUserData to retrieve the item they liked before.

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jzlnikola avatar image jzlnikola commented ·

That makes sense. We were thinking about that solution but we wanted to hear your opinion. Since we expect a decent amount of traffic we want to make sure that we’re doing it the right way!

And what about getting levels with most likes? I suppose we would have to do that with search, but what should we put in order by, since it’s the number of ratings that’s important?

Also is it possible to put the number of ratings in search requests select, so that we get the number of likes(ratings) immediately with search?

0 Likes 0 ·
kylemc@microsoft.com avatar image kylemc@microsoft.com jzlnikola commented ·

You should be able to use the counts in the Rating object to answer questions like "best rated" and "most liked". You should be able to Filter or OrderBy the properties to get the view you want.

https://learn.microsoft.com/en-us/rest/api/playfab/economy/catalog/search-items?view=playfab-rest#rating

If you're using the SearchItems API, expect to see aggregation latency as described here.

https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/catalog/ratings#ratings-design-and-caching

0 Likes 0 ·
jzlnikola avatar image jzlnikola kylemc@microsoft.com commented ·

That's really helpful, thank you! And is there a way to get all items player made a review for?

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.