question

cqatproject avatar image
cqatproject asked

How to get other player's playfab ID using display name?

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

·
pfnathan avatar image
pfnathan answered

You can use GetAccountInfo

https://api.playfab.com/documentation/client/method/GetAccountInfo

API can accept the PlayFabId, OR the name, OR the username, OR the email, and will return both the PlayFabID and the title_player_account as well.



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.

cqatproject avatar image cqatproject commented ·

Can you help me with this by giving a sample code?

0 Likes 0 ·
cqatproject avatar image cqatproject cqatproject commented ·

Because it says there that the playfabId is the required parameter to use this function, and the parameter I can provide is the displayname only. Can you please give me an example?

0 Likes 0 ·
brendan avatar image brendan cqatproject commented ·

Client/GetAccountInfo (the linked API call, above) does not have PlayFab ID as a required parameter. If you believe you're seeing something different, can you reply with the link to the doc page in question?

We have a number of samples available here: https://github.com/PlayFab/PlayFab-Samples. Specific to GetAccountInfo, there's actually an old post with an example of using the call to get the local player's info here: https://community.playfab.com/questions/115/205469398-Show-User-There-Playfab-ID.html. The only change for the case of using it to get a player's info via their Title Display Name would be the addition of setting that parameter (TitleDisplayName) in the request object.

0 Likes 0 ·
v-throch avatar image v-throch commented ·

Hello Brendan, I don't understand why GetUserAccountInfo doesn' work as GetAccountInfo.

I need to get other player's playfab ID using display name but server side..via cloud script.

Thanks you

0 Likes 0 ·
brendan avatar image brendan v-throch commented ·

They were made for very different purposes - server versus client usage. Basically, the server normally has the PlayFab ID already, where the client needed other lookup methods for cases where the player is manually entering a name or email address for lookup.

Can you describe the gameplay scenario you are trying to build? What is the context in which the client has display name without PlayFab ID, and where you don't want the client to query for the PlayFab ID of the other user.

0 Likes 0 ·
v-throch avatar image v-throch commented ·

Hello Brendan,

I want to execute a cloud script from client as following :

PlayFab::ClientModels::ExecuteCloudScriptRequest myRequest;

myRequest.FunctionName = "MyScript";

myRequest["FriendDisplayName"] = "toto 234";

With this FriendDisplayName, I want the cloud script to retrieve the FriendPlayfabID and push a key value into its userinternalData. The cloud script must be in charge of all.

My problem is that I can't send the FriendPlayfabID with my cloud script request except if I first throw another request to get the playFabID via GetAccountInfo.

If i break down the process into 2 steps, it works, but i was just wonderning if it could be possible to make it in 1 step.

Thank you

0 Likes 0 ·
Andy avatar image Andy ♦♦ v-throch commented ·

With the API as it is today, no, it's going to require two steps. This isn't the only case where it might be nice to have more overlap in functionality between the client and server. That's an error we're looking to improve over time. The updated entity API is a start in that direction. I've made a specific note to look into some functionality to do player PlayFabId lookups from the server.

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.