Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Graph API - Finding a users top friends

I am writing a android app that will pull in a list of all the users friends so they can tag them in the photo but displaying a large box of the friends with their photo instead of a list. Because some people have 500+ friends, we all know their are only a handful (maybe 50) that are friends they actively communicate on Facebook by comments or being tagged in photos. I would like to be able to just pull their top xxx friends as it seems Facebook does this same thing on their site, but I just cant find anything in the Graph API to do this task.

Anyone have any pointers?

like image 895
Brad Wickwire Avatar asked Aug 11 '11 04:08

Brad Wickwire


People also ask

How do I get friend count on Facebook API?

You need to generate token (by clicking on Get Token you will get it) with data you want from facebook API, need to select friends option to get the friend count.

What data can I get from Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

How do I get Facebook Page Insights on graph API?

You can access Page Insights by typing /insights after the name of your page in the URL field. This command will retrieve all of the Insights associated with your Page. Type "/insights" after your company name. Click the Submit button.


1 Answers

The other way of doing it is, make a Graph API request for the status messages posted by the user, the friends who have commented or liked his status are the ones with whom he/she interacts the most, doing this is pretty simple, you can use this:

    $statuses = $facebook->api('/me/statuses');

    foreach($statuses['data'] as $status){
    // processing likes array for calculating fanbase. 

            foreach($status['likes']['data'] as $likesData){
                $frid = $likesData['id']; 
                $frname = $likesData['name']; 
                $friendArray[$frid] = $frname;
            }

         foreach($status['comments']['data'] as $comArray){
         // processing comments array for calculating fanbase
                    $frid = $comArray['from']['id'];
                    $frname = $comArray['from']['name'];
    }
}

keep counters as per your choice, and it will be done.

like image 191
Ram Kumar Avatar answered Nov 04 '22 03:11

Ram Kumar