For example, if you look at the facebook plugin page (link below), notice that it shows a “Platforms” row at the top of the page and only Android and iOS are supported.
I’m not aware of any, but that doesn’t mean it hasn’t been done. Maybe you should leave this thread open so if someone did implement a Lua based facebook library, they can offer it here.
For example, if you look at the facebook plugin page (link below), notice that it shows a “Platforms” row at the top of the page and only Android and iOS are supported.
I’m not aware of any, but that doesn’t mean it hasn’t been done. Maybe you should leave this thread open so if someone did implement a Lua based facebook library, they can offer it here.
We are porting one of our games to Windows and OS X.
Would be great if we could implement facebook login.
Here is what I found on the facebook docs:
“To use Facebook Login in a desktop app, you’ll need to be able to embed a web browser (sometimes called a webview) within the app to perform the login process”
And here is what should be done (from their docs):
Invoking the login dialog
Your app must initiate a redirect to an endpoint which will display the login dialog:
This endpoint has the following required parameters:
client_id. The ID of your app, found in your app’s dashboard.
redirect_uri. The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set to https://www.facebook.com/connect/login_success.html.
Does that mean we have to open a web-view and then redirect to the above url?
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()
We are porting one of our games to Windows and OS X.
Would be great if we could implement facebook login.
Here is what I found on the facebook docs:
“To use Facebook Login in a desktop app, you’ll need to be able to embed a web browser (sometimes called a webview) within the app to perform the login process”
And here is what should be done (from their docs):
Invoking the login dialog
Your app must initiate a redirect to an endpoint which will display the login dialog:
This endpoint has the following required parameters:
client_id. The ID of your app, found in your app’s dashboard.
redirect_uri. The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set to https://www.facebook.com/connect/login_success.html.
Does that mean we have to open a web-view and then redirect to the above url?
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()