Created
February 1, 2015 02:03
-
-
Save coronarob/b2f48636debee4ca6f0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
settings = { | |
plugins = | |
{ | |
["facebook"] = | |
{ | |
publisherId = "com.coronalabs" | |
}, | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local widget = require( "widget" ) | |
local function onComplete( event ) | |
print( "event.name:", event.name ) | |
print( "event.type:", event.type ) | |
if ( event.data ) then | |
-- event.data is a table of friends returned. | |
-- event.data[1] will be the first friend returned. | |
-- Each friend will have a list of fields returned like: | |
----- event.data[1].firstName | |
----- event.data[1].fullName | |
----- event.data[1].lastName | |
----- event.data[1].id | |
end | |
end | |
local facebook = require( "facebook" ) | |
-- Listener for "fbconnect" events | |
local function listener( event ) | |
if ( "session" == event.type ) then | |
-- Upon successful login, request list of friends | |
if ( "login" == event.phase ) then | |
-- Show the friends picker | |
facebook.showDialog( "friends", onComplete ) | |
end | |
elseif ( "dialog" == event.type ) then | |
print( event.response ) | |
end | |
end | |
local FBAppID = "XXXXXXXXXXX" -- Facebook App ID from build.settings, without the "fb" prefix. | |
facebook.login( FBAppID, listener, { "publish_actions" } ) | |
local function showDialog( event ) | |
if ( event.phase == "ended" ) then | |
facebook.showDialog( "friends", onComplete ) | |
end | |
return true | |
end | |
local button = widget.newButton{ | |
label = "Pick Friends", | |
onEvent = showDialog, | |
} | |
button.x = display.contentCenterX | |
button.y = display.contentCenterY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment