question

Akio Yamazaki avatar image
Akio Yamazaki asked

How to get an opponent profile data?

I'm making 1 on 1 board game on web(use javascript). I use matchmaking API and complete successes. but response data has only Entity. I'd like to get an opponent profile(Display name and Avatar image URL).

How to get an opponent profile data?

Player Data
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

·
Citrus Yan avatar image
Citrus Yan answered

The Id of the Entity returned from GetMatch is the title_player_account id, and I am assuming that you want to retrieve the opponent’s profile using GetPlayerProfile, which uses the PlayFabId ( the same as the master_player_account id), is that correct?

If that’s your case, so the question now is how to get the PlayFab Id (master_player_account id) from the title_player_account id. The GetProfile API can retrieve it, it’s returned in GetEntityProfileResponse -> Profile -> Lineage -> MasterPlayerAccountId, so that you can use it with GetPlayerProfile to retrieve the opponent’s profile data. However, one thing to note is, by default, a player entity cannot use GetProfile to retrieve other player’s entity profile, you have two options:

  1. Use the server side logic to retrieve & return the PlayFabId back to the client side, for instance, using CloudScript. And, you can even retrieve & return the opponent’s profile as well, leaving all the job to server side.
  2. Add the following policy statement into the ENTITY GLOBAL TITLE POLICY ( Under GameManager -> Settings -> API Features), or do it with SetGlobalPolicy:
{
    "Action": "Read",
    "Effect": "Allow",
    "Resource": "pfrn:data--*!*/Profile/*",
    "Principal": "*",
    "Comment": "allow title player access other's profiles ",
    "Condition": {
      "CallingEntityType": "title_player_account"
    }
  }

So that you can retrieve the opponent’s PlayFab Id directly from the client side, and proceed with GetPlayerProfile.

2 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.

Akio Yamazaki avatar image Akio Yamazaki commented ·

Thank you for your help! I resolved it by changing the GlobalPolicy!

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Akio Yamazaki commented ·

Please also note that, by changing the policy, players can access each other's entity profiles (including entity objects, statistics, etc.). If you have some private data stored for players in entity profiles, you may need to add some additional policies to avoid that.

1 Like 1 ·

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.