Skip to content

Instantly share code, notes, and snippets.

@coronarob
Created February 1, 2015 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coronarob/b2f48636debee4ca6f0f to your computer and use it in GitHub Desktop.
Save coronarob/b2f48636debee4ca6f0f to your computer and use it in GitHub Desktop.
settings = {
plugins =
{
["facebook"] =
{
publisherId = "com.coronalabs"
},
},
}
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