Hi,
I need to implement a leaderborad in my HTML5 game. But I can’t find anything about leaderboards in Id.net Javascript documentation. Does your Javascript API support it?
Thanks!
Hi,
I need to implement a leaderborad in my HTML5 game. But I can’t find anything about leaderboards in Id.net Javascript documentation. Does your Javascript API support it?
Thanks!
Hi, Yes, the JS SDK does support scores.
To show Scores:
ID.leaderboard();
That can be called inside a jquery click event or where ever needed.
To Submit a score:
ID.api('leaderboard/submit', 'POST', {score: 123 }, function(response){
console.log(response);
});
Keep in mind these should be called inside the id.net init event, to make sure ID is loaded first.
window.idAsyncInit = function() {
ID.Event.subscribe('id.init', function(){
put inside here...
EDIT: There is a new API for highscores. See the docs here http://dev.id.net/docs/javascript/game-api/#leaderboards-reference
ok. thanks!
another questions are how to make an autologin and how to get pid ?
thanks to all for the answer! )
one more question. submitting a score does not affect on leaderboard. it has no any information.
( pid=“55f15c7cd5593049b000008d”, incoming response = null )
Hi, the pid is returned after a user has logged in. There are examples here, http://dev.id.net/docs/javascript/the-basics/
For auto login in JS, you can test if a user is already logged in using Get Login Status, more details on the bottom of this page, http://dev.id.net/docs/javascript/auth-functions/
after submitting a score it should return {status: ok} if it worked, or an error if it failed. Are you sending pid and score when submitting?
sure after auto login I send pid and score when submitting, but response = null.
p.s.: the links you sent on JS API docs do not explain a silent auto login without any windows.
What does your code look like? for me it’s working.
window.idAsyncInit = function ()
{
idnet_shell.prototype.init = function( _shell )
{
ID.Event.subscribe(‘id.init’, function ()
{ // this is an auto login I asked for…
$.ajax({
url: “https://www.id.net/api/user_data/autologin?app_id=” + app_id,
jsonp: “callback”,
dataType: “jsonp”,
success: function( dataAutologin )
{
if( dataAutologin.error )
{
_shell.init_cb( false, null );
}
else
{
var arr = [];
arr[0] = dataAutologin.sessionKey;
arr[1] = dataAutologin.user.nickname;
arr[2] = dataAutologin.user.pid;
_shell.init_cb( true, arr );
}
}
});
});
// init the JS interface
ID.init({ appId: app_id });
}
idnet_shell.prototype.show_leaderboard = function()
{
ID.leaderboard();
}
idnet_shell.prototype.submit_score = function( _pid, _score )
{
ID.api('leaderboard/submit', 'POST', { pid: _pid, score: _score }, function(response)
{
console.log(response);
});
}
};
now it returns:
code
-32099
data
Object { status=401, data="{"error":"not_accepted_a...efore making requests"}"}
data
"{"error":"not_accepted_application","error_description":"Application has to be reviewed before making requests"}"
status
401
message
"INVALID_STATUS_CODE"
so submitting success depends on app approving status ?
That is a bad way to login because it mixes 2 different authentications. Please use the links I sent in my second post.
I can approve your app, what’s the app id?
the app_id is “55eed467e694aabeab000082”
ok all set now.
thanks! now it works!
sometimes when trying to show leaderborad I see warning window
and no way to return back to game. the same on desktop and mobile…
I tested the game’s high scores and didn’t see the issue. Is it still happening? It may have been a temporary issue.
yes, it is. I saw it each day. sometimes several times in a row.
p.s.: the point is that you can’t close that window to continue a game.
Ok, thanks for reporting. I let the developer working on this feature know about the problem.
Hi, we have a new leaderboards API for Javascript. See the docs here, http://dev.id.net/docs/javascript/game-api/#leaderboards-reference
When i used ID.leaderboard(); - then leaders tabel show correct, but when i used new wersion leaderboards api ID.GameAPI.Leaderboards.list(options), then leaderboards doesn’t works?