question

Alexander Surmann Flügel avatar image
Alexander Surmann Flügel asked

How to list members of a group?

Hello,

I have this Unity C# code snippet to list the members of a group. However, I am not sure what to do inside the foreach loop. Can someone please assist me? Thank you!

     void ListMembers(string groupID)
     {
         PlayFabGroupsAPI.ListGroupMembers(new ListGroupMembersRequest
         {
             Group = EntityKeyMaker(groupID)
         }, result => {
             foreach (var item in result.Members)
             {
                 //What I do here?
             }
         }, OnSharedError);
     }
unity3dShared Group 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

·
Neils Shi avatar image
Neils Shi answered

If you want to list the members in the group, you can refer to the following example code (which shows how to retrieve the members’ entity id and entity type in the group) :

 public void ListGroupMem()
     {
         PlayFabGroupsAPI.ListGroupMembers(new ListGroupMembersRequest()
         {
             Group = new PlayFab.GroupsModels.EntityKey { Id = "227CDCCxxxxxxxxx",Type = "group" }
         },
     result => {
         foreach (var item in result.Members)
         {
             //What I do here?
             foreach(var member in item.Members)
             {
                 Debug.Log(member.Key.Id);
                 Debug.Log(member.Key.Type);
             }
         }
     },
     error => {
         Debug.Log("Got error");
         Debug.Log(error.GenerateErrorReport());
     });
     }

For more info, Please refer to Groups - List Group Members - REST API (PlayFab Groups) | Microsoft Learn.

10 |1200

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

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.