Skip to content

Instantly share code, notes, and snippets.

@dankerizer
Forked from adamloving/fb-fan-export.js
Created January 7, 2014 05:02

Revisions

  1. @adamloving adamloving revised this gist Sep 19, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fb-fan-export.js
    Original file line number Diff line number Diff line change
    @@ -51,7 +51,7 @@ var OnResponse = function(e) {
    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('http://www.facebook.com/profile.php?id=' + userId + ',' + userData.title + ',' + userData.subtitle + ',' + userData.pic)
    }

    console.log('Downloaded: ' + totalUsersDownloaded + ' of ' + e.payload.count)
  2. @adamloving adamloving revised this gist May 29, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fb-fan-export.js
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ var usersPerPage = 100;
    var totalUsersDownloaded = 0;
    var throttle = 3000; // how long to wait between pages
    var startPage = 0;
    var endPage = 10;
    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() {
  3. @adamloving adamloving revised this gist Mar 27, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fb-fan-export.js
    Original file line number Diff line number Diff line change
    @@ -74,7 +74,7 @@ var downloadUsers = function(page) {
    page: page,
    limit: usersPerPage,
    node_id: nodeId,
    class: 'FanManager',
    'class': 'FanManager',
    post_form_id: document.getElementById('post_form_id').value,
    fb_dtsg: document.getElementsByName('fb_dtsg')[0].value,
    lsd: null,
  4. @adamloving adamloving revised this gist Mar 27, 2011. 1 changed file with 25 additions and 0 deletions.
    25 changes: 25 additions & 0 deletions fb-fan-export.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,28 @@
    /*
    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;
  5. @adamloving adamloving revised this gist Mar 27, 2011. 1 changed file with 18 additions and 34 deletions.
    52 changes: 18 additions & 34 deletions fb-fan-export.js
    Original file line number Diff line number Diff line change
    @@ -1,44 +1,21 @@
    /*
    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 = 100;
    var startPage = 0;
    var endPage = 10;

    // Find the social graph node ID (page profile ID) by peeking at some UI configuration data
    // Find the social graph node ID (page profile ID) by peeking at meta tags
    var getNodeId = function() {
    for (key in window.__UIControllerRegistry) {
    var pagelet = window.__UIControllerRegistry[key];

    if (pagelet._context_data && pagelet._context_data.profile_id)
    return pagelet._context_data.profile_id;
    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
    @@ -60,11 +37,18 @@ var OnResponse = function(e) {

    // 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: getNodeId(),
    node_id: nodeId,
    class: 'FanManager',
    post_form_id: document.getElementById('post_form_id').value,
    fb_dtsg: document.getElementsByName('fb_dtsg')[0].value,
  6. @adamloving adamloving revised this gist Jan 21, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fb-fan-export.js
    Original file line number Diff line number Diff line change
    @@ -81,4 +81,4 @@ var downloadUsers = function(page) {
    result = req.send();
    }

    downloadUsers(0);
    downloadUsers(startPage);
  7. @adamloving adamloving revised this gist Jan 18, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions fb-fan-export.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    /*
    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
  8. @adamloving adamloving created this gist Jan 18, 2011.
    81 changes: 81 additions & 0 deletions fb-fan-export.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,81 @@
    /*
    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 = 100;

    // Find the social graph node ID (page profile ID) by peeking at some UI configuration data
    var getNodeId = function() {
    for (key in window.__UIControllerRegistry) {
    var pagelet = window.__UIControllerRegistry[key];

    if (pagelet._context_data && pagelet._context_data.profile_id)
    return pagelet._context_data.profile_id;
    }
    }

    // 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 data = {
    edge_type: 'fan',
    page: page,
    limit: usersPerPage,
    node_id: getNodeId(),
    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(0);