Question

I have a facebook application that is published at facebook platform and i used facebook API to invite friends and i have succeeded in creating invitation form but the problem is that when u invite friend and send invitation and the invitation request sent to the user and the user accept it this friend appears again in the friend list that can be invited again

For example :

i have friend in my friend list named X and when i send invitation to him the invitation is sent and and X accept the invitation and when i try to send invitation again the friend X appears again in the list that i can select from to send invitation this means that may i send an invitation to this user (X) and he is already playing the game i need to know how to fix this problem so friends appear in the friend list (for invitation )only friends that not use the application.

My application at the following link My Game application visit it and see the problem exactly after inviting friends they will appear again is this normal in any game application?

thanks in advance for any reply

Was it helpful?

Solution

In FBML if you are using the friend-selector you can pass it an array exclude_ids. If you use the api to find the users' friends who are already using your app, you can exclude them this way.

This also works in the multi-friend-selector which sits inside an fb:request-form tag.

EDIT: the array of users to exclude can be obtained through the api call Friends.getAppUsers.

Following example uses the .NET Facebook Developer Toolkit. (mainly because that's how I've done it before!)

CODE BEHIND:

public string CURRENT_USER_FRIENDS = "";

//Call this function on pageload or where you like
private void PopulateFriendsData()
{
//exclude friends who already have the app from the inviter
string UsersToExclude = string.Empty;
IList<long> AppUserFriends = this.Master.API.friends.getAppUsers();
foreach (long L in AppUserFriends)
{
    UsersToExclude += L.ToString() + ",";
}
CURRENT_USER_FRIENDS = UsersToExclude.TrimEnd(',');
}

PAGE:

<fb:multi-friend-selector 
actiontext="Select the friends you want to invite" 
rows="3" 
exclude_ids="<%=CURRENT_USER_FRIENDS%>"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top