Submit Highscore

How to submit a highscore with gamenetwork?

See this guide:   http://docs.coronalabs.com/guide/cloud/leaderachieve/index.html

local loginParams = {} loginParams.type = "user" loginParams.email = "CloudUser@domain.com" loginParams.password = "CloudUserPassword" cloud.login( loginParams )

Thank you, I did it using the login parameters such as those written above:

But now how can I do to implement Login with facebook?

http://docs.coronalabs.com/guide/cloud/manageUsers/index.html

Thank you, I was able to login with facebook, but I can not post the highscore with facebook user, this is my code:

local access\_token = "" local appId = "XXXXXXXXXXXX" local leaderboards = cloud.leaderboards if(fbLoginInProgress) then return end fbLoginInProgress = true local function listener( event ) if ( event.type == "session" ) then if ( event.phase == "login" ) then access\_token = event.token facebook.request( "me?fields=id" ) elseif(event.phase == "loginFailed" ) then removeLoading() fbLoginInProgress = false native.showAlert( ERROR, event.response, { OK } ) end elseif ( event.type == "request" ) then -- event.response is a JSON object from the FB server local t = json.decode(event.response) local loginParams = {} loginParams.type = "facebook" loginParams.facebookId = t.id loginParams.accessToken = access\_token cloud.login( loginParams ) end end --login function local function loginF() facebook.login( appId, listener, {"publish\_stream", "email"} ) end --score function local function postscore() score = 1500 local leaderboardID = "51bc63xxxxxxxxxxx" leaderboards.submitHighScore( leaderboardID, score ) end --a button for login local loginFButton = widget.newButton{ id = "loginFAccount", left = 200, top = 207, width = 300, height = 205, fontSize = 55, font = system.nativeFont, labelColor = { default={ 244, 126, 32, 255 }, over={ 135, 70, 18, 255 } }, defaultColor = { 0, 0, 0, 0 }, overColor = { 0, 0, 0, 0 }, strokeColor = { 0, 0, 0, 0 }, label = "Login with Facebook", onRelease = loginF } -- a button for post score local postHighscore = widget.newButton{ id = "score", left = 700, top = 207, width = 300, height = 205, fontSize = 55, font = system.nativeFont, labelColor = { default={ 244, 126, 32, 255 }, over={ 135, 70, 18, 255 } }, defaultColor = { 0, 0, 0, 0 }, overColor = { 0, 0, 0, 0 }, strokeColor = { 0, 0, 0, 0 }, label = "Post Score", onRelease = postscore }

works even print (access_token), but I do not understand why my score is not submited

Are you looking for any call backs when the leaderboard is submitted?  Is the response code showing a success or a failure?

If you mean something like this:

local function leaderboardsListener( event ) if ( event.type == "submitHighScore" ) then print( event.response ) end end leaderboards.setListener( leaderboardsListener )

i don’t know how to look at it because for facebook login i use a android device and i can’t see the print(), you know how to do?

Ok I solved:

facebook.request("me", "GET", {fields="id"}, onGetResult)function onGetResult(event) local userId = event.response.id end

the problem was the user ID. :smiley:

Do you have the “adb” (Android Debug Bridge) tools installed?

See this guide:   http://docs.coronalabs.com/guide/cloud/leaderachieve/index.html

local loginParams = {} loginParams.type = "user" loginParams.email = "CloudUser@domain.com" loginParams.password = "CloudUserPassword" cloud.login( loginParams )

Thank you, I did it using the login parameters such as those written above:

But now how can I do to implement Login with facebook?

http://docs.coronalabs.com/guide/cloud/manageUsers/index.html

Thank you, I was able to login with facebook, but I can not post the highscore with facebook user, this is my code:

local access\_token = "" local appId = "XXXXXXXXXXXX" local leaderboards = cloud.leaderboards if(fbLoginInProgress) then return end fbLoginInProgress = true local function listener( event ) if ( event.type == "session" ) then if ( event.phase == "login" ) then access\_token = event.token facebook.request( "me?fields=id" ) elseif(event.phase == "loginFailed" ) then removeLoading() fbLoginInProgress = false native.showAlert( ERROR, event.response, { OK } ) end elseif ( event.type == "request" ) then -- event.response is a JSON object from the FB server local t = json.decode(event.response) local loginParams = {} loginParams.type = "facebook" loginParams.facebookId = t.id loginParams.accessToken = access\_token cloud.login( loginParams ) end end --login function local function loginF() facebook.login( appId, listener, {"publish\_stream", "email"} ) end --score function local function postscore() score = 1500 local leaderboardID = "51bc63xxxxxxxxxxx" leaderboards.submitHighScore( leaderboardID, score ) end --a button for login local loginFButton = widget.newButton{ id = "loginFAccount", left = 200, top = 207, width = 300, height = 205, fontSize = 55, font = system.nativeFont, labelColor = { default={ 244, 126, 32, 255 }, over={ 135, 70, 18, 255 } }, defaultColor = { 0, 0, 0, 0 }, overColor = { 0, 0, 0, 0 }, strokeColor = { 0, 0, 0, 0 }, label = "Login with Facebook", onRelease = loginF } -- a button for post score local postHighscore = widget.newButton{ id = "score", left = 700, top = 207, width = 300, height = 205, fontSize = 55, font = system.nativeFont, labelColor = { default={ 244, 126, 32, 255 }, over={ 135, 70, 18, 255 } }, defaultColor = { 0, 0, 0, 0 }, overColor = { 0, 0, 0, 0 }, strokeColor = { 0, 0, 0, 0 }, label = "Post Score", onRelease = postscore }

works even print (access_token), but I do not understand why my score is not submited

Are you looking for any call backs when the leaderboard is submitted?  Is the response code showing a success or a failure?

If you mean something like this:

local function leaderboardsListener( event ) if ( event.type == "submitHighScore" ) then print( event.response ) end end leaderboards.setListener( leaderboardsListener )

i don’t know how to look at it because for facebook login i use a android device and i can’t see the print(), you know how to do?

Ok I solved:

facebook.request("me", "GET", {fields="id"}, onGetResult)function onGetResult(event) local userId = event.response.id end

the problem was the user ID. :smiley:

Do you have the “adb” (Android Debug Bridge) tools installed?