Thanks for the quick response.
Here is a simple example that I’m using to get the player name and id from facebook and put into a player table. With this code, right after que player login into facebook, it requests his name and id. The base from this code I get from this doc: https://docs.coronalabs.com/daily/guide/social/implementFacebook/index.html
The first problem is that this doc says that you can only have one facebook listener that you inform when you do the login. But, the way I implemented, I think its not a good practice, I mean, I should call a function to login first, and then when its done, I call the other function to request my info, and then when its done I return the values to my game so I can show them on screen. The problem is I can’t know when the login or the request is done. I think it should have something like the onComplete method. So the last thing I tried was to use the “event.didComplete”, in the docs it says that it returns true when its done and false when not. https://docs.coronalabs.com/daily/api/event/fbconnect/didComplete.html
But I could not make it work, it always returns me false.
Thank you again for the help.
local facebook = require( "facebook" ) local json = require( "json" ) local player = {} local function facebookListener( event ) print( "event.name:" .. event.name ) --"fbconnect" print( "isError: " .. tostring( event.isError ) ) print( "didComplete: " .. tostring( event.didComplete ) ) print( "event.type:" .. event.type ) --"session", "request", or "dialog" if ( "session" == event.type ) then --options are "login", "loginFailed", "loginCancelled", or "logout" if ( "login" == event.phase ) then local access\_token = event.token --code for tasks following a successful login local params = { fields = "id,first\_name,last\_name" } facebook.request( "me", "GET", params ) end elseif ( "request" == event.type ) then print("facebook request") if ( not event.isError ) then local response = json.decode( event.response ) player.id = response.id player.name = response.first\_name .. " " .. response.last\_name end elseif ( "dialog" == event.type ) then print( "dialog", event.response ) --handle dialog results here end end local fbAppID = "000000000000" --replace with your Facebook App ID facebook.login( fbAppID, facebookListener, { "user\_friends", "email" } )