4

Is there a way to get the whole Facebook friends list using an api!

I've tried a lot of thing and here's my shot:

FacebookClient f = new FacebookClient(access_token);
f.IsSecureConnection = true;
dynamic friendlist = await f.GetTaskAsync(@"https://graph.facebook.com/me/friendlists?access_token="+access_token);
t.Text = JsonConvert.SerializeObject(friendlist);

But all I got is an empty data!
Can anyone help me?

ekad
  • 14,436
  • 26
  • 44
  • 46
Louay Sleman
  • 1,794
  • 2
  • 15
  • 39

3 Answers3

6

The friendlists endpoint is deprecated, as you can see in the breaking changes log: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#tagged-users-4-4

It would not have been what you expected anyway, it was only for lists, not friends directly. Access to all friends is not possible since a very long time. You can only get data of users/friends who authorized your App. You can use the /me/friends endpoint for that.

Another thread about getting all friends: Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application

Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86
andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • thanks for your comment I've already take a look on that and you're right but on the other hand there's some apps that get all friends list do you have any ideas .... thanks for advance – Louay Sleman Apr 30 '18 at 22:41
  • it is impossible, that is a fact. if there is some app, please add a link. some companies may have a special deal with facebook, but i doubt that this will be for long after the recent data scandal. – andyrandy Apr 30 '18 at 22:41
  • there's a lot of apps and that's one you can find it here https://play.google.com/store/apps/details?id=com.WhoVisitedMyFacebook.app&hl=en – Louay Sleman Apr 30 '18 at 22:57
  • 3
    i highly suggest not trying to install those "who viewed your profile" apps. it is not possible to get all friends since v2.0 of the graph api (we are at v2.12 now), and it was NEVER possible to get people who viewed your profile. do people really still believe that? :/ – andyrandy May 01 '18 at 07:08
  • I'm not talking about the app or what he named I'm just saying that those apps still get all friends list and I don't know how .... – Louay Sleman May 01 '18 at 07:24
  • 2
    they can only scrape the profile, which is not allowed on facebook. there is no way at all. i will add a link to another thread to my answer, where a facebook employee answers the question. if you don´t believe me, maybe you believe facebook ;) – andyrandy May 01 '18 at 08:58
  • I believe you ... I'm just wonder how they did it and if these way not allowed then thanks for advance you're really help me – Louay Sleman May 01 '18 at 09:05
  • @luschn, you're asking about such apps that can access friend lists from Facebook are, mostly the gaming one's. Clash of Clans, etc. They all connect your Facebook friends to send them gifts and keep them engaged. – Trishant Pahwa Aug 03 '20 at 08:58
  • 2
    those gaming apps still can only access friends who play the game already – andyrandy Aug 04 '20 at 05:49
1

This is not the API way but for starters who want one time download list of friends

  1. Go to the friend list page: https://www.facebook.com/friends/list
  2. Scroll all the way down so that all friend list loads
  3. Press F12 to open developer tools, click on console tab firefox developer tools console firefox

A. Show in console copy paste following script in console and hit enter.

    var accumulated = "";
    for (var el of document.querySelectorAll('[data-visualcompletion="ignore-dynamic"]')) {
        var name = el.getAttribute("aria-label");
        if(name!= null && name != "null"){
            accumulated = "Name:"+name +", "+ accumulated;
            console.log(accumulated);
            accumulated = "";
        }else{
            var a = el.getElementsByTagName("a")[0];
            if(a){
                accumulated += "Profile URL: "+ a.getAttribute("href");
                //console.log(a);
            }
        }
    }

B. Download a .json file copy paste following script in console and hit enter.

    var exportObj = [];
    var accumulated = "";
    for (var el of document.querySelectorAll('[data-visualcompletion="ignore-dynamic"]')) {
        var name = el.getAttribute("aria-label");
        if(name!= null && name != "null"){
            exportObj.push({name: name, profileURL: accumulated});
            accumulated = "";
        }else{
            var a = el.getElementsByTagName("a")[0];
            if(a){
                accumulated += a.getAttribute("href");
            }
        }
    }
    
    var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj));
    var downloadAnchorNode = document.createElement('a');
    downloadAnchorNode.setAttribute("href",     dataStr);
    downloadAnchorNode.setAttribute("download", "friendsList.json");
    document.body.appendChild(downloadAnchorNode);
    downloadAnchorNode.click();
    downloadAnchorNode.remove();

Note: pseudo code tested in firefox

Nitin Sawant
  • 7,278
  • 9
  • 52
  • 98
0

There is another way can give you an access to your all friend list names by downloading a copy of your facebook information data by selecting friends and following checkbox and wait till your file is ready then download it.

Abdelrahman Hatem
  • 1,028
  • 1
  • 9
  • 20