question

Jorge Tosar avatar image
Jorge Tosar asked

Inviting to Group using Username

Hi, we are trying to find a way to invite other players to a group using their username.

Every API call we've found requires the Entity Key of the player we want to invite, but all we have is his username. And have't found a way to convert that over.

Is there a standard way to invite players to groups?

Thanks!

entities
1 comment
10 |1200

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

Jorge Tosar avatar image Jorge Tosar commented ·

When trying to get another players profile I get a Not Authorized, which makes sense. But we want to see who invited us to the group, and all we have is the InvitedByEntity key. So how can we get information (like DisplayName and AvatarUrl) from another player? This is the same challenge for us when trying to get basic group info about the group inviting us when all we have is it's key.

I'm sure I'm missing something obvious here. Any thoughts?

Thanks

0 Likes 0 ·

1 Answer

·
Citrus Yan avatar image
Citrus Yan answered

To invite players to a group , you should use the InviteToGroup API, which I suppose is also the way you are doing. Now the problem you are facing is to use username in exchange of Entity Key of that player, in this case, you can use the GetAccountInfo API to do that, a sample response from it would be:

{
    "code": 200,
    "status": "OK",
    "data": {
        "AccountInfo": {
            "PlayFabId": "xxx",
            "Created": "2020-03-23T01:34:46.53Z",
            "Username": "xxx",
            "TitleInfo": {
                "DisplayName": "xxx",
                "Created": "2020-03-23T01:34:46.811Z",
                "AvatarUrl": "xxxx",
                "TitlePlayerAccount": {
                    "Id": "xxx",
                    "Type": "title_player_account",
                    "TypeString": "title_player_account"
                }
            }
        }
    }
}


The “TitlePlayerAccount” property refers to the Entity Key of that player which you can pass to the InviteToGroup API.

About the second question: So how can we get information (like DisplayName and AvatarUrl) from another player?

GetAccountInfo is still the way to go, however, this time you pass the PlayFabId for the API to consume, the PlayFabId is the id of the master_player_account you received from the ListMembershipOpportunities API:

...
"InvitedByEntity": {
                    "Key": {
                        "Id": "xxx",
                        "Type": "title_player_account",
                        "TypeString": "title_player_account"
                    },
                    "Lineage": {
                        "master_player_account": {
                            "Id": "xxx",
                            "Type": "master_player_account",
                            "TypeString": "master_player_account"
                        }
                    }
                },
...

Please also note that you’ll also need to enable client access to Avatar URL and Displayname in [Game Manager] - > [Settings] -> [Client Profile Options] so that the GetAccountInfo API can return such info to the players.

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

Jorge Tosar avatar image Jorge Tosar commented ·

Thanks for the reply.

The second call to GetAccountInfo with the PlayFabId seems to be the piece I'm missing.

I tried it but did not have much luck, this is what I'm seeing:

The results from ListMembershipOpportunities gives me an InvitedByEntity that has no lineage at all (InvitedByEntity.Lineage.Count is 0). If I try the call to GetAccountInfo with InvitedByEntity.Key I get what you'd expect: "User not found".

Oddly enough, the InvitedEntity does have a proper lineage with a "master_player_account", and it works with GetAccountInfo just fine.

The issue is we want the AccountInfo for the Entity who invited you (InvitedByEntity), but I can't seem to get a working "master_player_account" PlayFabId for it.

Thanks!

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Jorge Tosar commented ·

Could you please share your titleId, id of the group, and PlayFabId of the two players? And, would it be ok that we create a test account in your title to investigate further?

1 Like 1 ·
Jorge Tosar avatar image Jorge Tosar commented ·

Thanks for looking at it. Here is a screenshot that shows all the variables (Ids etc.) from ListMembershipOpportunities result. My titleId is 19BAB.

I noticed that the returned InvitedByEntity actually has the Type of "title" and it's using my titleID as the Id for the entity? I don't understand that.

So here is the flow I'm using to get my information: Username -> GetAccountInfo -> TitleInfo.TitlePlayerAccount -> InviteToGroup

Thanks.

0 Likes 0 ·
Jorge Tosar avatar image Jorge Tosar Jorge Tosar commented ·

So I tried it again by creating a new group and all that and this time it seemed to work (I can see the InvitedByEntity actually has a Lineage I can use). I'm not sure what's going on with the case above.

Perhaps I deleted the original Player that created the invitation but I highly doubt that. Anyway, looks like it's working

0 Likes 0 ·
Jorge Tosar avatar image Jorge Tosar commented ·

I can confirm it was because we created that group invite on the Dashboard, which is why our InvitedByEntity was the title id.

Thanks for the help!

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Jorge Tosar commented ·

Yes, that would be a title level operation, glad to hear that it's working now:)

1 Like 1 ·
Jorge Tosar avatar image Jorge Tosar commented ·

Another possibility is the person who created that group invitation did it through the Dashboard so that's why we see the titleId as the InvitedByEntity?

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.