question

Matthew Miskiewicz avatar image
Matthew Miskiewicz asked

How to look up player via TitleDisplayName in Cloudscript Server

As title says. In Client you can call GetAccountInfo, but I can't find an analogous call server side. Any help appreciated! :-)

Context: players should be able to invite friends to their clan (entity group) by knowing just their friend's display name.

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

·
Sarah Zhang avatar image
Sarah Zhang answered

Server API GetUserAccountInfo is an analogous call that can be used to get user account info via PlayFabId, but according to its API reference, it doesn’t support get user account info via TitleDisplayName. Admin API GetUserAccountInfo supports it. You can refer to the following CloudScript code to try to call Admin API on CloudScript. But, generally, Admin methods aren't supposed to be used in Cloud Script because Cloud Script is a "runtime" tool, where the Admin API is more of a "development time" tool. Using HTTP requests to call admin API is just a workaround temporarily. So, you can try to add a feature request to enable the TitleDisplayName in the corresponding Server API.

About the implement of inviting friends to players’ entity groups via their display names. A possible situation is the DisplayName that a player can see is on the UI layer that a game developer decides to expose. In order to interact with the target “DisplayName”, clients should already have requested complete player account info. If so, it would be unnecessary to request the PlayerId again. For example, if they want to invite their friends to the clan, clients simply provide an invitation button on the friend’s profile page, otherwise, pop out a friend list for invitation will also do the job. You can choose the solutions most suit your case.

handlers.AdminGetUserAccountInfo = function (args, context) {
    let url = "https://[TitleId].playfabapi.com/Admin/GetUserAccountInfo";
    let method = "POST";
    let contentBody = JSON.stringify(args);
    let contentType = "application/json";
    let headers = { "X-SecretKey": "[SecretKey]" };
    let responseString = http.request(url, method, contentBody, contentType, headers);
    let responseJSONObj = JSON.parse(responseString);
    return (responseJSONObj);
}
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.

Matthew Miskiewicz avatar image Matthew Miskiewicz commented ·

Got it, thanks! I can work with that to engineer a solution.

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.