23

I was wondering if it was possible to query the following:

  • List of (all) users who like my facebook page, and
  • Additional information those users have made publicly available (beyond first and last name)

Basically looking to generate detailed marketing stats of users who like my facebook page, if possible. Any suggestions or alternatives welcome.

Thank you.

MrRay
  • 952
  • 2
  • 10
  • 16
  • Here is [the best answer][1] I found on the subject. It even give you a PHP script [1]: http://stackoverflow.com/a/10906320/244911 – LE GALL Benoît Aug 19 '14 at 14:48
  • possible duplicate of [Facebook API: Get fans of / people who like a page](http://stackoverflow.com/questions/4018849/facebook-api-get-fans-of-people-who-like-a-page) – Peter O. Sep 12 '14 at 05:45

8 Answers8

30

I am afraid this is NOT possible, follow this bug for more information.

Another proof is the page_fan table you will notice that only the uid field is indexable so you need to know the user id to search it and not the page_id, as you know if a user "likes" a page this would mean he is a "fan" of that page.


After being actively working with the Facebook API for a while now, and following the announcements and API releases (and deprecations) along with the introduction and changes of policies, I can understand that Facebook will only share info about their users by letting them explicitly do so (a.k.a interact/authorize your Apps).

And hence the best thing to do in the absence of such feature is:

  1. Understand your audience through Page Insights
  2. Collect fans interests & info by creating custom apps through Page Tabs and using other Facebook features like Questions
ifaour
  • 38,035
  • 12
  • 72
  • 79
  • 2
    I agree that this is not possible. I've tried every possible permutation of api calls, permissions, access tokens etc that might possibly provide you with a list of a page's fans/likes over the past couple days with no success. Anyone who says they are able to do this either hasn't actually tried it or must have somehow lucked in to a beta test of the ability as described in your link to the bug page. – B_. Mar 04 '11 at 01:45
11

Alright, nobody wants to break Facebook's TOS but they have tied our hands on our own basic data. So, scraping is illegal, but not saving a page. What I have done (and note that I needed this for offline purpose anyway): Go to https://www.facebook.com/browse/?type=page_fans&page_id={FAN PAGE ID} Scroll down until you have all of your fans. Save this page on your local machine, let's say, Facebook.html. Now, using ruby and nokogiri:

require 'nokogiri'
>true
f = File.open('/your_path/Facebook.html')
doc = Nokogiri::HTML.parse(f.read)
doc.xpath('//div[@class="fsl fwb fcb"]/a').each {|link| puts link.content}
Thiago Ganzarolli
  • 1,161
  • 12
  • 17
6

Do a graph search likes this: "People who like [your fanpage's name]". You will all the result.

Then create shortcut on your browser with this javascripts code, it will click on the View more link and scrolling until all result are shown in the page:

javascript: i = 0;minutes = 30;counter = minutes * 60;function repeatScroll() {
if (i < counter) {window.scrollTo(0, document.body.scrollHeight);i++;}    
setTimeout(repeatScroll, 1000);}repeatScroll();

After that, create other shortcut and run this js code to retrieve all UID from the search result:

javascript:var txt="";e=document.getElementsByClassName("FriendRequestOutgoing");
for(var i=0; i<e.length; i++) {v=e[i].getAttribute("data-profileid");
if(v) txt+=v+"\n"}document.body.innerHTML="<textarea>"+txt+"</textarea>";

A textarea box will appear in the screen with all uid inside. Just copy it to your notepad and import into your Custom Audience in Facebook Ad Manager.

I created and use this code everyday to get all UID with criterial I need. You can launch any graph search you want. This is homemade code, so using it without your own responsibility :)

Enjoy them.

ntuan16
  • 198
  • 2
  • 9
  • Your second code didn't work for me, so I edited(class and attribute), this works:`javascript:var txt="";e=document.getElementsByClassName("lfloat"); for(var i=0; i"+txt+"";` – Harkály Gergő Jul 15 '15 at 17:35
5

It's possible, just not with FQL anymore.

Do a GET of https://www.facebook.com/browse/?type=page_fans&page_id={FAN PAGE ID} and scrape out the users.

Viola.

Kevin
  • 77
  • 1
  • 1
2

Now you can get people on your page with this link, or click on Settings button, than on People on the left sidebar. https://www.facebook.com/[PAGENAME]/settings/?tab=people_and_other_pages

If you want to get all the user's photo, press F12 and add these codes to the Console:

javascript:i=0;minutes=30;counter=minutes*60;function repeatScroll(){if(i<counter){window.scrollTo(0, document.body.scrollHeight);i++;}setTimeout(repeatScroll,1000);}repeatScroll();

than, when you reached the bottom of the page:

javascript:var txt="";e=document.getElementsByClassName("img"); for(var i=0; i<e.length; i++) {v=e[i].getAttribute("src"); if(v) txt+="<img src='"+v+"'>\n"}document.body.innerHTML="<textarea>"+txt+"</textarea>";

To display photos: create a HTML page and first insert these lines into that file:

<meta charset="utf-8">
<style>img { width:21px; margin:-1px; }</style>
<div style="width:851px; height:315px;background-color:white;">
<!-- PASTE HERE PHOTOS' CODE YOU GET -->
<span style="color:#3B5998;font-weight:bold;font-size:20px;margin-bottom:4px;">600 like, thank you!</span>
<!-- PASTE HERE PHOTOS' CODE YOU GET -->    
</div>
Harkály Gergő
  • 733
  • 8
  • 18
0

Then create shortcut on your browser with this javascript code, it will click on the View more link and scrolling until all result are shown in the page:

i = 0;
minutes = 30;
counter = minutes * 60;
function repeatScroll() {
    if (i < counter) {
        window.scrollTo(0, document.body.scrollHeight);
        i++;
    }    
    setTimeout(repeatScroll, 1000);
}
repeatScroll();

After that, create other shortcut and run this js code to retrieve all UID from the search result:

var e=document.getElementsByClassName("fsl fwb fcb");
var ids = [];
for(var i = 0 ; i < e.length; i++){
  ids.push(JSON.parse(e[i].childNodes[0].getAttribute("data-gt")).engagement.eng_tid);
}
console.log(ids);
Karup
  • 2,024
  • 3
  • 22
  • 48
Renato
  • 1
0

load all list

i = 0;
minutes = 30;
counter = minutes * 60;
function repeatScroll() {
    if (i < counter) {
        window.scrollTo(0, document.body.scrollHeight);
        i++;
    }    
    setTimeout(repeatScroll, 1000);
}
repeatScroll();

get id

var e=document.getElementsByClassName("_3cb8");
var ids = [];
for(var i = 0 ; i < e.length; i++){
  ids.push(e[i].getAttribute("href"));
}
console.log(ids);
Hoang Le
  • 13
  • 5
-8

You can get it using facebook open graph.

https://graph.facebook.com/<your-page-name-or-page-id>/likes

For example :

https://graph.facebook.com/chickfila/likes

You need to send graph api call using "id" for more detail about user who like you page.

However, this call will retrieve the other Facebook objects that the page (Chickfila) has liked, NOT the users who have liked the Chickfila page.

bhamby
  • 15,112
  • 1
  • 45
  • 66
Rajesh Meniya
  • 753
  • 1
  • 7
  • 17