Sign In Register

How can we help you today?

Start a new topic
Answered

get player country from cloud code

 Hi ,


we are working on implementing leaderboard but we need to also show the country next to each player.


I look through the documentation but didn't know how to get the country for a player.


Thanks


Best Answer

Hi Ahmed


Sorry for the late reply.

You can get the players country using a AccountDetailsRequest

In cloud code this will be


var accountDetailsRequest = new SparkRequests.AccountDetailsRequest;
var response = Spark.sendRequestAs(accountDetailsRequest, playerId);


This will return the location json

var location = response.location;


To get the country

var country = location.country


The documentation on Account details request can be found here


Thanks

Katie





1 Comment

Answer

Hi Ahmed


Sorry for the late reply.

You can get the players country using a AccountDetailsRequest

In cloud code this will be


var accountDetailsRequest = new SparkRequests.AccountDetailsRequest;
var response = Spark.sendRequestAs(accountDetailsRequest, playerId);


This will return the location json

var location = response.location;


To get the country

var country = location.country


The documentation on Account details request can be found here


Thanks

Katie






1 person likes this
Login to post a comment