I am not able to get user profile

I am trying to let user to login my app using their facebook account. I am able to see the app authorization screen and I am able to get the login token in the login response. But I am not able to get user profile. I need the email and user facebook id after login.

local function fbLoginProcess(event) local facebook = require("plugin.facebook.v4") local json = require( "json" ) local function fbUser() local profile = facebook.request( "me" ) alert('Profile Response: '..tostring(profile)) end local function fbResponse(event) if event.type == 'session' then -- login local status = event.phase -- login, loginFailed, loginCancelled, logout alert('Status: '..status..', Token: '..event.token) fbUser() else alert('Other: '..json.decode(event.response)) end end facebook.login( fbResponse, {"public\_profile", "email"}) end btnFbLogin:addEventListener('tap', fbLoginProcess)

I get nil response in the facebook.request( “me” ) call.

I am using corona SDK Version 2016.2900 (2016.6.14) and was testing on Android device.

I fixed it.

 local function fbResponse(event) if event.type == 'session' then if event.phase == 'login' then fbToken = event.token fbStatus = 'profile' facebook.request('me','GET', {fields="id,email,name"}) end elseif event.type == 'request' then local response = event.response if fbStatus == 'profile' then local fbData = json.decode(response) -- alert('ID: '..fbData['id']..', Email: '..fbData['email']..',Name: '..fbData['name']) fbId = fbData['id'] fbEmail = fbData['email'] fbName = fbData['name'] end end end local function fbLoginProcess(event) facebook.login( fbResponse, {"public\_profile", "email"} ) end btnFbLogin:addEventListener('tap', fbLoginProcess )

I fixed it.

 local function fbResponse(event) if event.type == 'session' then if event.phase == 'login' then fbToken = event.token fbStatus = 'profile' facebook.request('me','GET', {fields="id,email,name"}) end elseif event.type == 'request' then local response = event.response if fbStatus == 'profile' then local fbData = json.decode(response) -- alert('ID: '..fbData['id']..', Email: '..fbData['email']..',Name: '..fbData['name']) fbId = fbData['id'] fbEmail = fbData['email'] fbName = fbData['name'] end end end local function fbLoginProcess(event) facebook.login( fbResponse, {"public\_profile", "email"} ) end btnFbLogin:addEventListener('tap', fbLoginProcess )

Hello boscotwcheung, are there any way to use facebook.request() in another button, for example for request a score? I dont want to request score only when the user login, i need to request every time that they check this. Please help me with that. (and sorry for my english, im speak spanish)

Can you try btnFbLogin:addEventListener(‘tap’, fbLoginProcess2 ) and fbResponse2 to get other response you needed?

Hello boscotwcheung, are there any way to use facebook.request() in another button, for example for request a score? I dont want to request score only when the user login, i need to request every time that they check this. Please help me with that. (and sorry for my english, im speak spanish)

Can you try btnFbLogin:addEventListener(‘tap’, fbLoginProcess2 ) and fbResponse2 to get other response you needed?