Inviting friends in facebook application

Go To


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

2009-06-16 14:29
by Ahmy


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!)


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(',');


actiontext="Select the friends you want to invite" 
2009-06-16 14:39
how can i add these id's it is set in the page sourece and i will not know the user friends except from the code so h can i set these id's from code behind? i am using C# under 2008 and the multi-friend-selector is FBML tag not HTML tag that i can pass it attributes values from code behind how can i do that - Ahmy 2009-06-16 14:51
are you using a facebook .Net toolkit like - RYFN 2009-06-16 14:58
No i am not using it i need to set the Id's of users excluded from the multi-friend-selecto - Ahmy 2009-06-16 15:00
Are you accessing the facebook api from your code behind in c#?

if so you can use the following api call to get the users' app using freinds: - RYFN 2009-06-16 15:07

edited my answer to show example in C# using aforementioned toolkit. although you're not using it, the example may be of use to you! (may be someone else will provide a different example - RYFN 2009-06-16 15:21
nothing new as i don't know how to supply the id's from code behind or is there any method to select friends who haven't used the application yet but this tags need to fill the attribute of id's and how can i do that - Ahmy 2009-06-17 09:18
You can pass the ID's from the code behind to the FBML using a public string, and referencing it in your FBML like this <%=Public_String%> as shown in the example.

On load this will bind the value of public_string from your code behind into your tag.

or are you asking how to access the api from C# ?

please edit your original question to make it clearer what you are asking.. - RYFN 2009-06-17 11:10

Mr.Zeus i have tried what u wrote and used silver tags to call puplic string but the page clashed when i use excludeids="<%=CURRENTUSER_FRIENDS%>" so how can i solve this bug? thanks for ur attentio - Ahmy 2009-06-17 13:07
I have traced the page and the problem from API.friends.getAppUsers(); and when i mended it by using fbservice and traced the ID returned i discovered that it returns ID's that is already online and logged in to the application not in general the ID's that use the application did u get what i mean - Ahmy 2009-06-17 13:50
friends.getAppUsers() will only get the ID's of people who are using your app AND are a friend of the logged in user. These are the ID's you will want to Exclude in your friend selector.

if you are having problems with the api itself, it might be worth asking in the facebook dev forums here: - RYFN 2009-06-17 14:51

Ah! I think I understand... you can only get the ID's of users who have given your app permission. If you are allowing users to interact with your app without asking them to give your app permission, you can't get their ID's or profile details as far as I know. see and for info on Authorizing your users - RYFN 2009-06-17 14:59
You have to know that any user use my application should be authorized to use the application i did'nt configure it but this is already exist and when i use your code again and i have logged in with two different users in 2 different browsers it obtains users who is already signed in not users who used the application and i am clear in my describtion so don't say to me that friends.getAppUsers() gets users use application i haver tried it and nothing of ur claims occurr - Ahmy 2009-06-18 07:37
I merely quoted what the documentation for Friends.getAppUsers says. If you are experiencing otherwise it would be best to ask in the facebook developer forum. I think I have helped all I can here - RYFN 2009-06-18 07:58
Thanks for ur help i know that but i need any method u have tried and know it's results well and i am too thankfull to u for ur sharing me this problem but when i try it it returns to me users who are online now at facebook and use this application but may be there is a method that do that as many games do u can go to the application and see urself - Ahmy 2009-06-18 08:02
Where are u Zeus? i am witting ur reply plz share me the proble - Ahmy 2009-06-18 10:52