Invite all Facebook friends

Hi guys, I’ve tried to follow several guides on the Corona website, but none of them worked for me.

I’ve already implemented Facebook in my App, everything seems to be setted in the right way.

Now I just want to retrive the list of all my Facebook’s friend and send them a notification that contains something like “play my brand new game”.

Actually I’m using the following code:

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 -- Listener for "fbconnect" events local function listener( event ) if ( "session" == event.type ) then if ( "login" == event.phase ) then facebook.showDialog( "friends", onComplete ) end elseif ( "dialog" == event.type ) then print( event.response ) end end local FBAppID = "my app ID" facebook.login( FBAppID, listener, { "publish\_actions", "user\_friends" } ) 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

The friend picker plugin pops up, but the list of friends is empty. 

What am I doing wrong? I really cannot understand.

Thanks for anyone that replies.

Best regards.

Facebook made some changes a while ago to stop developers adding methods which allow user’s to spam all of their friends.

“Friends” now only returns the list of friends who have also logged into the app. So if I’m playing “Estiennelorenzo-mania” or whatever your game is called, and none of my friends have logged into FB in “Estiennelorenzo-mania” the “/friends” API call will return nothing. 

If one of my friends has also logged in, then I will see their name. 

What you can do is use the “apprequests” API, and specify that you want to get a list of friends who have NOT played the game before (because you don’t want to annoy someone who already has the game by sending them invites) by using the “app_non_users” filter:

facebook.showDialog("apprequests", {title="Invite your friends!", message="Why not try out Estiennelorenzo-mania, filters = "app\_non\_users"})

The dialog will then show a list of friends, but it only shows a few of them (my understanding is that FB send you the list of friends most likely to install the game). However there is also a search bar at the top, so the user can search for a particular friend in this case.

Facebook made some changes a while ago to stop developers adding methods which allow user’s to spam all of their friends.

“Friends” now only returns the list of friends who have also logged into the app. So if I’m playing “Estiennelorenzo-mania” or whatever your game is called, and none of my friends have logged into FB in “Estiennelorenzo-mania” the “/friends” API call will return nothing. 

If one of my friends has also logged in, then I will see their name. 

What you can do is use the “apprequests” API, and specify that you want to get a list of friends who have NOT played the game before (because you don’t want to annoy someone who already has the game by sending them invites) by using the “app_non_users” filter:

facebook.showDialog("apprequests", {title="Invite your friends!", message="Why not try out Estiennelorenzo-mania, filters = "app\_non\_users"})

The dialog will then show a list of friends, but it only shows a few of them (my understanding is that FB send you the list of friends most likely to install the game). However there is also a search bar at the top, so the user can search for a particular friend in this case.