I have a local text file containing Facebook ids, one per line, like this:


These ids actually are those of my Facebook friends interested in jazz.

Now I would like to create a "jazz" Facebook friends list ("Facebook friends lists" are Facebook feature) to easily invite them to jazz events.

How to create this Facebook friends list?

  • You might want to approach it in another way...with ids, the only way that will work is an API method. Are you looking to quickly move friends to lists?
    – phwd
    Commented Jul 17, 2011 at 14:21
  • My (non-facebook) address book has for each person: an optional facebook id, and a list of tags. The tags are more up-to-date that anything in my facebook. So I want to regularly create facebook friends lists based on those tags. When inviting people to a facebook event, this will allow me to more easily invite all people that have a certain tag. Maybe there is an application that does this?
    – nic
    Commented Jul 17, 2011 at 15:03

3 Answers 3


Facebook API would probably be the most natural. However, if you have access to Linux you can at least extract the friends' names using wget as follows (see also wget for fetching Facebook profile/friend pages):

wget -U Mozilla --wait 1 "https://www.facebook.com/profile.php?id=938751234570943"

This will download the publicly available content and depending on privacy settings the name of the contact will appear and could be parsed.

  • Maybe my question is not clear enough, let me put it in other words: I already have the ids as local data. I need to push them back to Facebook in a way that Facebook will create what it calls a "friends list".
    – nic
    Commented Aug 17, 2011 at 4:54

You can use the Facebook API to get the information you want and then add them to a database (or your definition of list).

In order to use that data, you need to query Facebook and although I'm not 100% sure, in order to do it, (even public data) you will need authorization from the user.

  • I should have been clearer: "friends list" are a Facebook thing, you can see them after clicking "Edit friends". I don't want to export anything FROM facebook, I want to import the list TO facebook.
    – nic
    Commented Jul 17, 2011 at 13:34

I ended up writing a bash script to compare Facebook and my address book.

Before running this script, I go to my Facebook friends list "jazz", and copy the generated HTML source into jazz.html.

When I run the script, it shows which jazz-tagged contacts are missing from Facebook, and I proceed to add them manually.

The jazz-addressbook line depends on your particular address book format, so please adapt it.


# Create a text file containing the Facebook ids of all the people in my Facebook friends list "jazz"
cat jazz.html | sed -e "s/li class/\n/g" | grep "checkableListItem selectedCheckable" | sed -e "s/.*value=\"//g" | sed -e "s/\".*//g" | grep -v "Done" | sort > jazz-facebook

# Create a text file containing the Facebook ids of all the people marked "jazz" in my address book
cat address-book.xml | depends on your address book format | sort > jazz-addressbook

echo "Missing from Facebook:"
diff jazz-facebook jazz-addressbook | grep ">" | sed -e "s/> //g"

echo "Missing from address book:"
diff jazz-facebook jazz-addressbook | grep "<" | sed -e "s/< //g"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.