question

wangying avatar image
wangying asked

SetProfileLanguage process

What is the best practice for player setting their own ProfileLanguage. I tried SetProfileLanguage on client side but it seems that player's EntityToken is not allow to set. Or I should do it via cloudscript but do not find doc about Profile and Authentication api on cloudscript aspect.

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

For clarification, players are allowed to access their own entity profiles by setting EntityTokens. After you call PlayFab Authentication APIs using PlayFab SDKs, such as call the LoginWithCustomID, the player’s entity token will be contained in the API response and be filled to the pre-defined variable -- Authentication Context automatically. When you call the Entity APIs, such as SetProfileLanguage, PlayFab will read the Authentication Context programmatically then send it with the request body to API URLs together. This process should work.

Do you mean you met some errors when calling SetProfileLanguage on the client? If so, could you please provide the detailed development platform, your code snippets, and the specific error messages for our reference?

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

wangying avatar image wangying commented ·

I filled with wrony entityid. Now it is worked.

By the way is there any way call entity api in cloudscript.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang wangying commented ·

Yes, you can call the Entity API using the method entity.xxxx on the CloudScript. You can find the sample code in the title's default CloudScript revision 1.

Players should call the Entity API ExecuteEntityCloudScript to execute the CloudScript functions that contians Entity API calls so that you can get their own entity profile using context.currentEntity.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Sarah Zhang commented ·

The sample code could be this.

// This an example of a function that calls a PlayFab Entity API. The function is called using the 
// 'ExecuteEntityCloudScript' API (https://api.playfab.com/documentation/CloudScript/method/ExecuteEntityCloudScript).
handlers.makeEntityAPICall = function (args, context) {


    // The profile of the entity specified in the 'ExecuteEntityCloudScript' request.
    // Defaults to the authenticated entity in the X-EntityToken header.
    var entityProfile = context.currentEntity;


    // The pre-defined 'entity' object has functions corresponding to each PlayFab Entity API,
    // including 'SetObjects' (https://api.playfab.com/documentation/Data/method/SetObjects).
    var apiResult = entity.SetObjects({
        Entity: entityProfile.Entity,
        Objects: [
            {
                ObjectName: "obj1",
                DataObject: {
                    foo: "some server computed value",
                    prop1: args.prop1
                }
            }
        ]
    });


    return {
        profile: entityProfile,
        setResult: apiResult.SetResults[0].SetResult
    };
};
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.