Using multi_friend_selector.php and action with parameters

Jun 18, 2008 at 12:40 AM
Edited Jun 18, 2008 at 12:45 AM
Hi there,

I have been testing multi_friend_selector.php and I am using an "action" URL with a parameter (e.g. "invited.aspx?foo=bar"). However, when the multi_friend_selector returns and invokes my action URL (i.e. "invited.aspx"), it just strips out my original parameter (i.e. "?foo=bar") and tacks on its own parameters, including the ids[] list of invited members.

I need the original parameters intact to make my code work. I wonder if anyone else is seeing this, and whether there is a workaround for this so that the parameters are preserved in the action URL?

Jul 2, 2008 at 8:39 AM
Hi Sir,

I am developing a facebook application for college project.

This is a game in which I want to put invite friend facility of facebook and also add some points when user invites friend for this application.

So, how can I get ID list of users in querystring of Action URL when user send invitations to friend.

Sir, pls help me, because my semester on ending otherwise I want to develope a new project on other concept.


Jul 2, 2008 at 12:33 PM
Edited Jul 2, 2008 at 12:34 PM
Hello, ive had same problem earlier and found part of solution on one web page but i cant remember which so im gonna paste my code without disclaimer.

Add this methods to your code behind from which you want to call invite friends

        public static string MultiFriendSelector(string action, string markup, string actionText, string excludeList, string requestType, bool isInvite)
            Dictionary<string, string> parameterList = new Dictionary<string, string>();
            // parameterList.Add("method", "facebook.notifications.sendRequest");
            parameterList.Add("action", action);
            parameterList.Add("actiontext", actionText);
            parameterList.Add("api_key", ConfigurationManager.AppSettings["appkey"]);
            parameterList.Add("content", string.Format(System.Globalization.CultureInfo.CurrentUICulture, markup));
            parameterList.Add("exclude_ids", excludeList);
            parameterList.Add("invite", isInvite.ToString());
            parameterList.Add("type", requestType);
            parameterList.Add("sig", GenerateSignature(parameterList));

            // Build the query
            StringBuilder queryBuilder = new StringBuilder();
            foreach (string kvp in parameterList.Keys)
            queryBuilder.Remove(queryBuilder.Length - 1, 1);

            return "" + queryBuilder.ToString();
        private static string GenerateSignature(System.Collections.IDictionary 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)
                signatureBuilder.Append(String.Format(CultureInfo.InvariantCulture, "{0}={1}", key, parameters[key]));

            // Append the secret to the signature builder
            byte[] hash;

            System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
            // Compute the MD5 hash of the signature builder
            hash = md5.ComputeHash(Encoding.UTF8.GetBytes(signatureBuilder.ToString().Trim()));

            // Reinitialize the signature builder to store the actual signature
            signatureBuilder = new StringBuilder();

            // Append the hash to the signature
            foreach (byte hashByte in hash)
                signatureBuilder.Append(hashByte.ToString("x2", CultureInfo.InvariantCulture));

            return signatureBuilder.ToString();
        private static List<string> ParameterDictionaryToList(System.Collections.IEnumerable parameterDictionary)
            List<string> parameters = new List<string>();

            foreach (KeyValuePair<string, string> kvp in parameterDictionary)
                parameters.Add(String.Format(CultureInfo.InvariantCulture, "{0}", kvp.Key));
            return parameters;

After that call it like this:

            string url = MyStickers.CommonFunctions.MultiFriendSelector("ACTION_URL"
                            , txtMsg.Text + " &lt;fb:req-choice url=&quot;; label=&quot;Confirm&quot; /&gt;"
                            , txtMsg.Text, excludeIds.ToString(), "TITLE", true);

Now redirect your app to url that method returns
On your ACTION_URL you must do this to capture ids of ppl your user selected:

            string[] fbIds = Request.QueryString["ids[]"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);