Sign In Register

How can we help you today?

Start a new topic
Answered

Public Leaderboard

Hi, I'm trying to create a public leaderboard using the Javascript SDK, I just need to be able to display the leadboard on a html page for now Im authenticating with a test user but I was wondering if there is any better way to do this.


Thanks


Best Answer

Hi Hjupter,


That's a valid approach. Another way to do it would be to make a custom callback script and within it send a SparkRequest as a test player to send a LeaderboardDataRequest. The response object can just be set to scriptData for display on your page. While you would still require a player account to send the request this method will save you having to authenticate a player to achieve the reasults.


Regards,

Liam


Answer

Hi Hjupter,


That's a valid approach. Another way to do it would be to make a custom callback script and within it send a SparkRequest as a test player to send a LeaderboardDataRequest. The response object can just be set to scriptData for display on your page. While you would still require a player account to send the request this method will save you having to authenticate a player to achieve the reasults.


Regards,

Liam

This is just what I needed!.. it works like a charm!.. the whole process its faster and safer.

Oh forgot to say, Thank you so much Liam for the quick answer.

Hi Hjupter,


No problem !


Liam

Hi quick question, is it possible to redirect to another page using custom callbacks? .. Im trying to create an affiliate system where players click on a link with an affiliate id then set a cookie with it and redirect to the appstore download then read that cookie and assign a segement based on the affliate id. Any thoughts?

Hi Hjupter, 


You could pass the source in via the callback url and then check it in the callback script and set the appropriate url to redirect to in scriptData in the response.

 

https://{apikey}.{stage}.gamesparks.net/callback/{apikey}/{credential}/{credentialSecrect}/?source=MySource

//In the callback script
Spark.setScriptData("source", Spark.getData().source)

 

Will that work for you here ? 


Regards,

Liam 



I figured I can redirect by doing this 

 

Spark.setScriptData("RESPONSE_RAW", "<meta http-equiv=\"refresh\" content=\"0;URL='https://www.google.com/'\" />");

The problem is the cookie, I was able to set the cookie with this:

 

headers["Set-Cookie"] = "id="+affiliateId+"; Max-Age=2592000; path=/";

 But when I try to read the cookie from the callback it doesnt work, I suppose its related to this: https://support.gamesparks.net/support/discussions/topics/1000087288


So I guess I wont be able to do this for now.

Login to post a comment