Hi,
Hopefully a fairly simple question - I want to do a single Facebook request to get both a user’s email address and list of friends. So far I’ve managed to implement both through separate facebook logins, but I’m not sure how to do it through one login.
Here’s my code for the email login:
[lua]local function fbListener( event )
if event.type == “session” then
print(“session began”)
if event.phase == “login” then
myGameSettings.fbSessionToken = event.token
saveTable(myGameSettings, “myGameSettings.json”)
if myGameSettings.fbSessionToken then
print(“got FB session token”)
facebook.request( “me” )
end
end
elseif event.type == “request” then
if not event.isError then
local response = json.decode( event.response )
if response.email then
myGameSettings.email = response.email
saveTable(myGameSettings, “myGameSettings.json”)
end
end
end
end
facebook.login( fbAppID, fbListener,{ “email” } )[/lua]
My code for retrieving the list of friends is very similar, except that I use a second login function, [lua]facebook.login( fbAppID, fbListener2)[/lua] that calls [lua] facebook.request( “me/friends” ) [/lua] during the login event phase.