Take the 2-minute tour ×

I'm experimenting with making a Facebook web app. What I want to do is have one of those popup dialogs that let you select from all your friends. The user selects some friends, and when they click OK, the IDs of the friends select get stored into a Javascript array.

It looks like I could use FB.ui, but the examples I've seen are all requests, like posting on a wall or inviting someone to a page. I just want to load those IDs into an array. How can this be done?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You can use something like jQuery Facebook Multi-Friend Selector or implement it yourself using response from friends connection of user as source for data.

FB.ui isn't really going to help you since it's not providing a way of displaying users in a UI that you wish for functionality other than Requests.

If you're going with jQuery Facebook Multi-Friend Selector it's as simple as adding <div id="jfmfs-container"></div> to your page and using next JavaScript:

$("#jfmfs-container").bind("jfmfs.selection.changed", function(e, data) {
    // `data` is Array of objects like {id: USER_ID, name: USER_NAME}
    console.log("changed", data);

    // `userIds` is the array of users ids
    var userIds = $(this).data('jfmfs').getSelectedIds();
share|improve this answer
What if I wanted to also get the names associated with those IDs? How can I use getSelectedIdsAndNames()? –  node ninja Mar 12 '12 at 0:33

The Facebook Graph API lets you get a list of a user's friends, and you can use those ids in an array:



You can read the list of a User's friends by issuing an HTTP GET to /PROFILE_ID/friends with any valid access_token of the current session user. For example:


share|improve this answer
I know about that already and have used it. The problem is coding all the Javascript for the popup box. I thought that if I could use FB.ui then it would be easier to make the usual popup box seen in Facebook. –  node ninja Mar 11 '12 at 8:12

Your Answer


