Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Export Facebook Page Fans
For more detailed instructions on how to use this script, sign up with your email here:
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.
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: ' +;
lastResponse = e; // for debugging
for (userId in e.payload.user_info) {
var userData = e.payload.user_info[userId];
// console.log('' + userId + ',' + userData.title + ',' + userData.subtitle + ',' + userData.pic)
console.log('' + userId + ',' + userData.title)
console.log('Downloaded: ' + totalUsersDownloaded + ' of ' + e.payload.count)
if ( <= endPage && totalUsersDownloaded < e.payload.count) {
setTimeout(function() { downloadUsers( + 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');
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))
result = req.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment