Friends.GetUserObjects() is very slow

Jan 11, 2010 at 10:29 PM

Hi,

I created a winform application where I use the method "Friends.GetUserObjects()" to fill a listbox with all friend names.

        private void btn_GetFriends_Click(object sender, EventArgs e)
        {
            tbx_Output.Clear();
            IList<user> myfriends = facebookService1.Friends.GetUserObjects();

            foreach (user frnd in myfriends)
            {
                //tbx_Output.AppendText(frnd.name.ToString() + Environment.NewLine);
                clbx_Friends.Items.Add(frnd.name.ToString());
            }
        }

When I select a name from the listbox I want to get the profile picture of the selected friend also using the "Friends.GetUserObjects()" method.

        private void clbx_Friends_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            tbx_Output.Text = clbx_Friends.SelectedItem.ToString();

            IList<user> myfriends = facebookService1.Friends.GetUserObjects();

            foreach (user frnd in myfriends)
            {
                if (frnd.name.ToString() == tbx_Output.Text)
                {
                    tbx_Info.Text = frnd.pic_big.ToString();
                }
            }
        }


The problem is that the "Friends.GetUserObjects()" method takes a long time to execute (between 10-20 seconds).

Anyone know a faster solution?

thx

Jan 12, 2010 at 7:22 AM

try get all friend names by using FQL

Take a look this: http://wiki.developers.facebook.com/index.php/FQL

Jan 12, 2010 at 3:55 PM

agree.  FQL is ALWAYS the way to go for retrieving info when performance is a concern.

Jan 13, 2010 at 10:08 PM

This is indeed a loooooooot faster

Thx