The Official Weblog of Nathaniel Bailey

NathanielBailey.co.uk Blog and Information from and about Nathaniel Bailey.

Follow Nathaniel Bailey on Twitter
View Nathaniel Bailey's profile on LinkedIn http://facebooklogin.ws/2009/12/facebook-login/ Google+

I work in Online Marketing Development for some medium to large size companies in the UK doing SEO, Online Marketing and Coding. I like to spend my spare time playing online games such as BC2 Vietnam with my friends, and playing around with websites such as building them, making changes and keeping content up to date etc. I also work on and run a number of sites for online solutions from web hosting to game servers and much more. Read more about me and my sites at My Profile. Just another rocker/metal head, that cares for nothing much but having fun and lots of it!

How To Get List Of Fans On Facebook Page?

Written by On October - 8 - 2011

How to Export Facebook Page Fans/Likes!?

As you may have noticed by now, Facebook no longer lets non-admins view a page’s fans, and so at work last week, I had to get a list of the fans/likes from a ‘very large blue chip companies’ Facebook page in order to get a list of people to email them with some codes, but facebook no longer lets everyone simple view this user information any longer so I had to go off and do some searching on google!

I must have spent a good hour (if not more) googleing and reading the endless number of questions such as “how to get facebook page likes?” and all I could find was people searching the same as I was, with no help coming up anywhere soon :(

Then I did! I found what I was looking for! A script that I can enter in the console of any browser running any console plugin such as Firefox’s Firebug! All you have to do, is:
1. Open your browsers console
2. Enter the code below
3. Hit run and watch the script work its magic in downloading all those fans on your page!

Once you have the list, all you need to do is copy paste them from your console, slap them in an Excel spreadsheet, delete the columns you dont need and there you go, you have a full list of facebook usernames that have liked your page!

The following script will only work if you’re an admin on the page that you wish to get a fan/likes list from.

/*For more detailed instructions on how to use this script, sign up with your email here: http://adamloving.com/internet-programming/how-toexport-facebook-page-fans

DISCLOSURE: This javascript runs in your browser pretending to be you
looking through your page fans. Facebook should have no problem with this,
but who knows if they will think it is strange to see you looking through
all your fans so quickly (the script waits 3s before requesting each page).
I’ve had no problem running this so far for 1000s of page fans, but I
cannot be held liable if your Facebook account gets banned or your page
gets disabled for any reason for using this script.

INSTRUCTIONS:
1. Download Google Chrome Web browser (or Apple Safari)
2. Enable the developer tools
3. Open the javascript console and cut and paste the attached script into the console.

The script will fetch users 100 at a time and output the results into the console which you can then cut and paste into a CSV file.*/

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 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 = getNodeId();

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);

There are currently only two issues with this approach that I have noticed:
1. If you are not the page administrator, you only get ~60% of the fans for any given page (presumably based on privacy settings).
2. There seems to be a back end limit on 10,000 fans. In the script, after it requests 100 pages of 100, the same results set comes back for subsequent requests. I’ve tried different pages and page sizes. I’ve also tried using an offset parameter like the one documented with the graph API to no avail.

Here are some questions and answers for trouble shooting if you run into problems with the script:

1. I’m admin, but I keep getting a message saying “Sorry couldn’t find profile ID”, how do I fix this?
A. You have two options; 1. Use a good browser such as Firefox. 2. check your pages head and find the page ID(a long number) rather then the pages url which is what your most like on.

2. Which browsers has this been tested in? Will it work in any browser we want?
A. This script has been tested in Firefox 4, 5 & 6 (with firebug), Safari, and Chrome. The only one reported that it doesn’t work in is Safari, but there is no reason why it shouldnt work with all browsers that have a console and allow you to enter your own scripts for testing etc.

I highly recommend that you use FireFox (with FireBug) when using this script as it has been the best so far from my testing. Chrome works ok, but you need to get the page ID yourself, where as FireFox does it all for you and all you need to do is simply copy paste!

(Note: The opinions expressed on this blog in its posts and replies are the opinions of their respective authors and not those of www.nathanielbailey.co.uk)

Comments are closed.