Gist Power Tip: Export Facebook Page Fans

by Adam Loving on September 28, 2009

October 13th 2011 update: This blog post is out of date. Recent Facebook changes broke the script and I’m working to fix it. Please enter your email to be notified when the new export script is available.

Your email ==>  







Businesses that embrace social media are faced with the challenge of communicating with customers on Facebook, Twitter, and other social networks. While philosophically I think this fragmentation is good, it is critical to be able extract, evaluate, and communicate with your user base wherever they may find you.

Facebook member and fan lists are not very portable. Even within Facebook, it isn’t obvious whether a Facebook Group or Facebook Page is better for communicating with customers. Gist is an emerging as a social Swiss Army knife (and social CRM) that can help solve this problem.

One thing that has always annoyed me about Facebook Pages is that there is no way to export fans. I’ve discovered workable hacks for downloading the member list from both groups and pages.

For Facebook groups, you can use the handy Export group members to CSV application. It uses the Facebook API to export members in to a handy Comma Separated Value file, which you can in turn import into Outlook or Gist.

Export Facebook group members

Using the EGMCSV app, select your group and the attributes “Facebook ID”, “Full name”, and “Picture URL”. Once you have a CSV file, edit the column names to those below.

  • facebook_id
  • Name
  • facebook_pic_big

These are undocumented CSV columns that Gist supports. They are required to track that the contact came from Facebook. Gist will automatically download their photo.

Import CSV into Gist

In Gist, click the “Account” link, then “Other/CSV” under “Connect More Accounts”. Once Gist has processed your file, contacts will start to appear.

Gist contact import

Getting fans from a Facebook page is not yet supported by the Facebook API. Luckily, the Facebook Web interface uses a simple AJAX/JSON call to supply the data when you view the page.

Gist Fans

My strategy to set this data free was to sniff the network traffic with the Wireshark tool, then replay the HTTP calls with a ruby script. The script below will iterate over the page’s fans, save the pages as JSON in plain text files, then load the text files and convert them to CSV files in the format we used above for groups. Note that if you run this you will need to substitute the value of your cookies and the form values in the HTTP post body. This insures you are authenticated as yourself when you connect to Facebook.

FacebookFanExport

Here is the text-friendly version of the Facebook Page Fan export script. I didn’t try this with pages for which I am not the administrator. I don’t see any reason why this wouldn’t work for your competitors’ fans.

The net result is a consolidated list of fans (prospects and leads) in Gist.

Gist People List

Gist will help de-dup contacts whether they originated from Facebook or Twitter. You could for example, use Gist to identify customers from your Web site that are on Twitter, and generate a special Twitter focused mailing to them. Gist has a ways to go to make this easier (bulk contact tagging by import), and also does not yet automate the communication side of the process (send a message to a person regardless of what network they are on).

wrote this post.

{ 82 comments… read them below or add one }

chanthou August 9, 2011 at 3:45 am

Hi all,

I want to create and update fan page from my website without login to facebook. Is there any API to create facebook fan page ?

adam August 11, 2011 at 4:38 am

I don’t think you can create one, but I believe you can post a status update – just like any other Facebook profile.

Ira Weissman August 16, 2011 at 8:29 pm

Hey Adam. This is awesome. It worked great for me for my Page. Quick question – any easy way to get the friend count for each FB user in the csv?

keno reyes August 20, 2011 at 10:17 am

thank you!

Perry September 7, 2011 at 10:12 am

Hi Adam,

I have been trying to use your facebook code, with no avail to export fans form a page I am admin of. This is the script that I am using. Please help :)

var uri = ‘/ajax/social_graph/fetch.php?__a=1′;
var lastResponse = null;
var usersPerPage = 100;
var totalUsersDownloaded = 0;
var throttle = 3000; // how long to wait between pages
var startPage = 0;
var endPage = 10; // change this if you have more than 1,000 fans

// Find the social graph node ID (page profile ID) by peeking at meta tags
var getNodeId = function() {
var metaTags = document.getElementsByTagName(‘meta’);
for (i in metaTags) {
var tag = metaTags[i];
if (tag.content && tag.content.match(/_([0-9]+)_/)) {
return tag.content.match(/_([0-9]+)_/)[1];
}
}
return null;
}

// Process the AJAX call response and dump the user data to the console
var OnResponse = function(e) {
console.log(‘— Page: ‘ + e.payload.page);
lastResponse = e; // for debugging

for (userId in e.payload.user_info) {
var userData = e.payload.user_info[userId];
totalUsersDownloaded++;
console.log(userId + ‘,’ + userData.title + ‘,’ + userData.subtitle + ‘,’ + userData.pic)
}

console.log(‘Downloaded: ‘ + totalUsersDownloaded + ‘ of ‘ + e.payload.count)
if (e.payload.page <= endPage && totalUsersDownloaded < e.payload.count) {
setTimeout(function() { downloadUsers(e.payload.page + 1); }, 3000);
}
}

// Make an AJAX call for the data using FB's AJAX library
var downloadUsers = function(page) {
var nodeId = profileid;

if (!nodeId) {
alert('Sorry couldn\'t find profile ID');
return;
}

var data = {
edge_type: 'fan',
page: page,
limit: usersPerPage,
node_id: nodeId,
'class': 'FanManager',
post_form_id: document.getElementById('post_form_id').value,
fb_dtsg: document.getElementsByName('fb_dtsg')[0].value,
lsd: null,
post_form_id_source: 'AsyncRequest'
}

var req = new AsyncRequest()
.setURI(new URI(uri))
.setMethod('POST')
.setData(data)
.setHandler(OnResponse);

result = req.send();
}

downloadUsers(startPage);

Tilok September 12, 2011 at 4:57 am

Hi, is there any way to extract facebook fanpage creator’s/admin’s info? I need it badly. Please help me :(

adam September 14, 2011 at 6:24 pm

Sorry, I have not seen any way to get the creator’s (or admin’s) info.

Hugh Macken September 29, 2011 at 4:46 am

Just curious to know if there is any way to get birthdays exported as well?

Ruth October 6, 2011 at 7:19 pm

Hi Adam,

I would like to export my fans from one Facebook page to another. I can’t request a merge because they have slightly different names but they are the same musician (me). Is there a way to do this?

JohnyZ October 12, 2011 at 2:26 pm

I tried script from git in chrome and firefox with profile_id (nodeId) hardcoded (and dinamic from meta) and returns a 404 status after post, it seems they changed something in their ajax requests or is “me”:D.

Brian October 13, 2011 at 3:45 am

I get a 404 error as well, it looks like something was changed

adam October 13, 2011 at 5:29 am

Yes, the inner workings of Facebook changed. I’ve got a fix for those who previously purchased the premium script. It scrapes the data from DOM nodes instead of using Facebook’s AsyncRequest libraries.

JohnyZ October 13, 2011 at 3:59 pm

I find the new ajax route but it needs a little reverse engineering of the scripts. I hope it will be an update if i can’t/can hack this:D.

andre October 21, 2011 at 4:31 pm

where can i purchase your premium script?

Dandashi October 24, 2011 at 9:00 am

how can i purchase the premium script?

Jeff October 24, 2011 at 1:56 pm

Adam, I was a big fan of your old AJAX script. Have you figured out a new way to do this? I would purchase a “premium” script as well.

Jim October 31, 2011 at 7:28 pm

Hi, Adam. I’d be interested in the premium script as well.

Glen November 2, 2011 at 5:49 pm

You mentioned a work around for buyers of the premium script. Is this still for sale? If so I’m interested. Shoot me an email.

ole December 6, 2011 at 2:33 pm

When I copied the code and pasted it on javascript console (Chrome) it returns: SyntaxError: Unexpected token ILLEGAL

Please help.

Guillermo December 29, 2011 at 6:27 pm

hi adam, where could i get the script to get the info of my fanpage fans ?
thanks, best regards

John January 4, 2012 at 5:09 am

I sure could use a working script too! Just trying to get a list of likes off my business page so I can select a random person from the list of likes. Really just need names in the simplest sense. Any luck on an updated script? Or a premium version? Thanks much!

Kara January 6, 2012 at 8:18 pm

I’m interested in using this script too. please email me if you’ve gotten this to work. Happy to get a paid version as well. Thanks.

Daniel January 9, 2012 at 3:21 pm

Adam, Have you figured out a new way to do this? I would purchase a “premium” script as well.

senthilkumar January 10, 2012 at 7:21 am

Hi Adam,
I have face book page .That page is liked by more face book user.Is there any way to get face book user email id and profile id.Please help me in this problem if you know

Pierre May 8, 2012 at 7:13 am

Hi Adam,
Can you predict if you will get the script done? I would make a donation for it.
Thanks, Pi

J May 28, 2012 at 6:56 am

Adam, as with everyone, I am also interested in getting the emails of the “likers” of the pages I admin. Do advise if you are still offering a premium version for our purpose. Thanks!

Dylan June 22, 2012 at 6:46 am

How can I install the script, no clue at all!

Praful Akali July 31, 2012 at 1:50 pm

Adam, interested in getting the email ids of about 0.3 Mn members on our fan page but not familiar with scripting. Can you help us extract these ids without putting the page at risk from FB? How much would that cost?

Armin September 18, 2012 at 7:45 am

Hey,

It seems the new url is “https://www.facebook.com/ajax/browser/list/page_fans/?page_id=[THE_PAGE_ID]&edge=public_profile%3Afbpage_to_user&start=[OFFSET]&__user=[YOUR_USER_ID]&__a=1″ , but there is a limit of 500 users returned … bummer.

Volc March 12, 2013 at 10:52 pm

There is a new tool that allows anybody (not just group admins) to download an unlimited amout of users. Check it out:
http://goo.gl/4KDjZ

sherryll July 28, 2014 at 7:54 am

any update on how to extract emails on fanpages?

admin July 28, 2014 at 3:40 pm

Sherryl – Thanks for checking in. I haven’t researched it lately, and haven’t heard anything from Facebook about it. It has been quite a while so I will look again when I have the chance!

Leave a Comment

{ 6 trackbacks }