question

egon avatar image
egon asked

Azure Functions call to PlayFabProfilesAPI.GetProfilesAsync results are always null.

I have the below code snippet from an Azure Function:

 foreach ( var i in args.ids ) // create an entity for each of the other title_player_accounts
     entities.Add ( new EntityKey { Id = i, Type = "title_player_account" } );
    
 PlayFabSettings.staticSettings.TitleId = context.TitleAuthenticationContext.Id;
    
 var titleContext = new PlayFabAuthenticationContext
 {
     EntityId = context.TitleAuthenticationContext.Id,
     EntityToken = context.TitleAuthenticationContext.EntityToken,
     EntityType = "title"
 };
    
 var players = await PlayFabProfilesAPI.GetProfilesAsync ( 
     new PlayFab.ProfilesModels.GetEntityProfilesRequest
     {
         Entities = entities,
         AuthenticationContext = titleContext
     }
 );

 foreach ( var p in players.Result.Profiles )
     profiles.Add ( new PlayerProfile { titleId = p.Entity.Id, displayName = p.DisplayName } );
 return new { profiles };

The function works, I'm able to view the log stream in Azure Portal. The problem is, most of the title information is 'null', for instance, the DisplayName. Now, answers here say that I need to set InfoRequestParameters, but GetProfilesAsync doesn't accept InfoRequestParameters. Tell me I don't have to make one call using the title_player_account id, and then ANOTHER call to something like GetPlayerCombinedInfoAsync?!?

In other words, how do I get the DisplayName using GetProfilesAsync? Thanks in advance for any help.

Player DataapissdksCloudScript
5 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.

Neils Shi avatar image Neils Shi commented ·

May I know why you want to get a list of players’ display name?

0 Likes 0 ·
egon avatar image egon Neils Shi commented ·

Because I'd like to be able to display something like:

BigDaddyO vs. TheNinja

I don't want to display their username, which I assume should be treated just as if it were confidential information. The DisplayName can also be modified if they wish to change their "name".

Now, may I ask why you asked me that question? Have I made some sort of incorrect assumption as to the purpose of DisplayName?

Cheers.

0 Likes 0 ·
Neils Shi avatar image Neils Shi egon commented ·

DisplayName configured in Game Manager or via UpdateUserTitleDisplayName API cannot be retrieved via Entity Profile related APIs. The Display name in Entity data model is different from classic data model. The reason why I asked you because the best way to get players' DisplayName depending on the specific situation. According to your scenario (you only want to get a small number of DisplayName), you can use API GetPlayerProfile instead of GetProfiles.

0 Likes 0 ·
Show more comments

1 Answer

·
Neils Shi avatar image
Neils Shi answered

As a workaround, you can add Display name to the player's attributes when player is creating the matching ticket (For players who create matching tickets, getting their own Display name is straightforward). When the matchmaking is over, you can use API GetMatch to get players' attributes.

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.

egon avatar image egon commented ·

I hadn't gotten around to using attributes yet. That sounds promising. Thinking out loud though, having the client enter their display name means the value isn't server validated, and might potentially lead to spoofing other players' display names? That's not overly problematic, but it could potentially lead to misleading or inappropriate display names?

Thank you for the suggestion. I may look at implementing that right now.

0 Likes 0 ·
Neils Shi avatar image Neils Shi egon commented ·

Please feel free to let me know if there are any other questions.

0 Likes 0 ·

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.