Where is the multi friend selector in toolkit 2.0?

Sep 10, 2008 at 2:06 AM

I'm not able to find the multi-friend-selector function anymore in the Toolkit 2.0. It's there in release 1.6, (i haven't checked 1.7 yet) Has it been removed from the Toolkit? Without the function, how am I suppose to send requests to friends or invite friends to install applications?

Sep 10, 2008 at 6:09 AM
I'm curious, what did the code look like in the previous version(s)?
Sep 10, 2008 at 8:41 AM

in previous versions of the toolkit I was still using FBML to render a multifriendselector:

content="Add SomeApp <fb:req-choice url='<%=ADD_URL%>' label='Add SomeApp to your profile'/>"

<fb:multi-friend-selector max="20"
actiontext="Here are your friends who don't have SomeApp. Invite them!"
showborder="true" rows="5"


where CURRENT_USER_FRIENDS was a collection of some sort.

However, it'll need changing for the new layout, as apps no longer want to force adding straight away... worth looking at the FBML wiki for this request form. http://wiki.developers.facebook.com/index.php/Fb:request-form 
Note that there is a .NET example on the page, but it may be out of date, I've not tested this yet.

Sep 10, 2008 at 6:08 PM
In version 1.6 of the Toolkit, I can call MultiFriendSelector method directly off an instance of FacebookService object, and get a Multi-friend-selector URL back. For example:

Facebook.Components.FacebookService fbService = CreateFBService(userId);
string selectorUrl = fbService.MultiFriendSelector(actionUri, content, actionText, excludeList, inviteType, false, max);

The code here is easier to read, since I don't have to mix FBMLs with C#. For people using Iframe, this is a much better way to code. 

Any reasons why we can't bring this method back?


Sep 21, 2008 at 12:58 PM
Hey SilverBits -$0$0$0$0Did you resolve this? I also cannot find it in the 2.0 release of the code. Did you code it in yourself? If so, mind sending me a copy please? :)$0$0$0$0$0Thanks$0$0$0$0$0Chu$0
Sep 21, 2008 at 6:57 PM
Yes, I had to code it myself. I based my code on the toolkit 1.6 source code. I added my code in notifications.cs, but you can add it in other classes if you prefer. Hope it helps.



mfs static fields



private static string mfsContentParamKey = "content";



private static string mfsActionParamKey = "action";



private static string mfsActionTextParamKey = "actiontext";



private static string mfsInviteParamKey = "invite";



private static string mfsTypeParamKey = "type";



private static string mfsExcludeIdParamKey = "exclude_ids";



private static string mfsApiKeyParamKey = "api_key";



private static string mfsMaxFriendParamKey = "max";



private static string mfsSignatureParamKey = "sig";



private static char equalChar = '=';



private static char ampersandChar = '&';



private static string mfsUri = "http://www.facebook.com/multi_friend_selector.php?";







string multiFriendSelector(string applicationKey, string secret, Uri actionUri, string content, string actionText,



string excludeList, string requestType, bool isInvite, int max)




string results = string.Empty;



Dictionary<string, string> parameterList = new Dictionary<string, string>();



string.Format(CultureInfo.InstalledUICulture, content));


parameterList.Add(mfsTypeParamKey, requestType);

parameterList.Add(mfsActionTextParamKey, actionText);

parameterList.Add(mfsExcludeIdParamKey, excludeList);

parameterList.Add(mfsInviteParamKey, isInvite.ToString());


// parameterList.Add("image", imageUrl.ToString());






parameterList.Add(mfsActionParamKey, actionUri.ToString());

parameterList.Add(mfsApiKeyParamKey, applicationKey);

parameterList.Add(mfsMaxFriendParamKey, max.ToString());


// parameterList.Add("session_key", _sessionKey);







StringBuilder queryBuilder = new StringBuilder();


parameterList.Add(mfsSignatureParamKey, GenerateSignature(secret,parameterList));


// Build the query







foreach (KeyValuePair<string, string> kvp in parameterList)










queryBuilder.Remove(queryBuilder.Length - 1, 1);


return mfsUri + queryBuilder.ToString();




internal string GenerateSignature(string secret, IDictionary<string, string> parameters)




StringBuilder signatureBuilder = new StringBuilder();



// Sort the keys of the method call in alphabetical order



List<string> keyList = ParameterDictionaryToList(parameters);




// Append all the parameters to the signature input paramaters




foreach (string key in keyList)



String.Format(CultureInfo.InvariantCulture, "{0}={1}", key, parameters[key]));



// Append the secret to the signature builder








byte[] hash;



MD5 md5 = MD5.Create();



// Compute the MD5 hash of the signature builder


hash = md5.ComputeHash(





// Reinitialize the signature builder to store the actual signature


signatureBuilder =

new StringBuilder();



// Append the hash to the signature



foreach (byte hashByte in hash)



"x2", CultureInfo.InvariantCulture));



return signatureBuilder.ToString();




internal List<string> ParameterDictionaryToList(IEnumerable<KeyValuePair<string, string>> parameterDictionary)




List<string> parameters = new List<string>();



foreach (KeyValuePair<string, string> kvp in parameterDictionary)




String.Format(CultureInfo.InvariantCulture, "{0}", kvp.Key));




return parameters;



Sep 22, 2008 at 12:15 PM
Thanks - would you mind showing how you called it? I'm not exactly certain what all the parameters are actually expecting for the multiFriendSelector method.$0$0$0$0--Ryan$0
Sep 22, 2008 at 11:32 PM
Maybe I should have asked... does this work in the iframe version or is it only the FBML?$0$0$0$0Thanks for your work$0$0$0$0$0Ryan$0
Sep 23, 2008 at 1:14 AM
It works in Iframe, not sure about fbml. Typically, you can use the request-form fbml tag in your fbml applications, which gives you more flexibility.

All these parameters are required, at least in the old FB platform. Haven't checked if FB has made changes to the API call in the new platform. My code should work fine, if not, please let me know.
Oct 27, 2008 at 1:40 AM
Edited Oct 12, 2009 at 2:35 PM

I wanted to do this in C#  and .NET 3.5 and I didn't want to edit the dlls since that would cause problems with me integrating the new dlls later.  So I did it all in the code behind very simply.   If you use the IFRame master page, this code will work if you just change the URL

Facebook Developer Toolkit 2 Multi Friend Selector

Dec 18, 2008 at 7:43 PM

I was able to use MaxxedMan's Code ( did not understand the var etc  - but changed it to String's etc) and get the Multiselect to show. I have this app running on my site ( not as a facebook canvas app). One thing I am still trying to figure out is how to get the user to come back to my site page once he finishes the invite. Any ideas ? Is it one of the parameters in the call ?

Jan 22, 2009 at 1:27 AM
MaxxedMan's code worked for me as well!  Does anyone know how to get the list of friends that were selected back into the codebehind to do additional processing with the selected records (i.e. logging the gifts sent to the DB).