local json = require("json") local myfbid W,H = display.contentWidth,display.contentHeight local userdatas local fbcode local function getFBData(token) local function networkListener( event ) if ( event.isError ) then print( "Network error!" ) else print(event.response) local decoded, pos, msg = json.decode( event.response ) if not decoded then print( "Decode failed at "..tostring(pos)..": "..tostring(msg) ) else userdatas = decoded end end end network.request( "https://graph.facebook.com/v2.3/me?fields=id,email,name,picture&access\_token="..token, "GET", networkListener ) end local function loopCheckIsLogin() local function networkListener( event ) if ( event.isError ) then else if event.status==200 then print("not yet") local decoded, pos, msg = json.decode( event.response ) if not decoded then print( "Decode failed at "..tostring(pos)..": "..tostring(msg) ) else fbcode:removeSelf( ) getFBData(decoded.access\_token) end else print("not yet") timer.performWithDelay( 5000, loopCheckIsLogin) end end end local headers = {} headers["Content-Type"] = "application/x-www-form-urlencoded" headers["Accept-Language"] = "en-US" local body = "type=device\_token&client\_id=1053169668066995&code=".. \_G.fbcode local params = {} params.headers = headers params.body = body network.request( "https://graph.facebook.com/oauth/device", "POST", networkListener, params ) end local function askLogin() local function networkListener( event ) if ( event.isError ) then else local decoded, pos, msg = json.decode( event.response ) if not decoded then print( "Decode failed at "..tostring(pos)..": "..tostring(msg) ) else fbcode = native.newTextField( W/2, H/4, 120, 30 ) fbcode.text = decoded.user\_code system.openURL("https://facebook.com/device") \_G.fbcode = decoded.code timer.performWithDelay( 5000, loopCheckIsLogin) end end end local headers = {} headers["Content-Type"] = "application/x-www-form-urlencoded" headers["Accept-Language"] = "en-US" local body = "type=device\_code&client\_id=1053169668066995&scope=public\_profile" local params = {} params.headers = headers params.body = body network.request( "https://graph.facebook.com/oauth/device", "POST", networkListener, params ) end askLogin()
Please read this https://developers.facebook.com/docs/facebook-login/for-devices