question

behnam@ordibeheshtstudio.com avatar image
behnam@ordibeheshtstudio.com asked

Get Account Info from another title

Hi,


I have two games and I want to set up a referral invitation.
Can I get playFab Id of the user that is in another game in unity like the way GetAccountInfo works?

unity3dAccount Management
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

·
Citrus Yan avatar image
Citrus Yan answered

Hi, can you explain to me about how does your referral invitation works? Which specific info do you need in order to implement the referral invitation? Correct me if I am wrong, you are saying that you have the PlayFab Id (Master Player Id) of a user in title1, now you want to get this user’s account info from title2 just like the way GetAccountInfo API works, is that right? As a matter of fact, PlayFab do have a server API GetUserAccountInfo which does exactly the same as the GetAccountInfo API. However, in order to call this API from title2, you must specify the API request EndPoint and Secretkey to be that of title1’s. It’s clearly not secure to make this call from the client, you must call it from CloudScript. For example, this is the code I tested in title2’s CloudScript to make a call to get title1 user's info:

function GetUserAccountInfoFromAnotherTitle(PlayFabId){
    let url = "https://your-titleId.playfabapi.com/Server/GetUserAccountInfo";
    let method = "POST";
    let contentBody = `{"PlayFabId": "${PlayFabId}"}`;
    let contentType = "application/json";
    let headers = { "X-SecretKey": "your-secretkey" };
    let responseString = http.request(url, method, contentBody, contentType, headers);
    let responseJSONObj = JSON.parse(responseString);
    return (responseJSONObj.data);
}


handlers.GetUserAccountInfo = function(args){
    var result = GetUserAccountInfoFromAnotherTitle(args.PlayFabId);
    return result;
}

Moreover, if you are familiar with entity programming model, saving account info using SetObjects API directly in the user’s title_player_account entity and using GetProfile API to retrieve it (it's cross-title, meaning that you can get other title's entity under the same studio) is also a workable way. If you are interested in it, you can refer to the doc to learn more.

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.