-1

I was under the impression Facebook only gave out lists of friends now who use a certain app.

In fact in this case that's all I want, but FB is returning all friends for all users I test with.

I'm using fields=installed but it seems to make no difference.

Here's the code I'm using, is there a way to just show friends of users who use the app?

$fb_user = $mysqli->real_escape_string($_REQUEST['user']);

$facebook = new Facebook(
    array( 
            'appId'  => $appID, 
            'secret' => $secret 
    )
);

//TO GET ACCESS TOKEN
$facebook->setExtendedAccessToken();
$access_token = $facebook->getAccessToken();

$fbFriends = 'https://graph.facebook.com/'.$fb_user.'/friends?fields=installed&access_token='.$access_token;

$friendsList = json_decode(file_get_contents($fbFriends),true);
StudioTime
  • 22,603
  • 38
  • 120
  • 207

3 Answers3

3

You are probably using an older App (created before end of April 2014). Just create a new one and you will only get the friends who are using the App too. It will still work to get ALL friends for older Apps until end of April 2015.

For older Apps, you would still get all friends with your call but there should be an "installed" field in the result, according to this thread: Facebook 'Friends.getAppUsers' using Graph API

Community
  • 1
  • 1
andyrandy
  • 72,880
  • 8
  • 113
  • 130
1

If you are still using the Facebook 1.0 API, you can convert your app to use the 2.0 API or 2.1 API.

https://developers.facebook.com/docs/apps/upgrading/

Depending on the platform you are using (web, android, or IOS) the process will be different, just follow the steps in that guide and fix any API calls that no longer conform to the new API and you should get your desired friends list.

Due to API changes in returned results for some functions, you may have to do a bit of work to fix your app to work with the new API. However you will need to upgrade eventually (API v1.0 is being phased out April 2015), so you might as well start sooner rather than later.

0

Thanks for all answers, this is surprisingly simple.

I've now future proofed my app until at least August 2016 by simply adding v2.1 to the data gathering URL as below:

$fbFriends = 'https://graph.facebook.com/v2.1/'.$fb_user.'/friends?access_token='.$access_token;

Now when making the call it only returns friends which are using the app.

StudioTime
  • 22,603
  • 38
  • 120
  • 207
  • careful with that, i am not entirely sure but i´ve found out that your app gets upgraded in certain cases when you use a newer version. and then you can´t use v1.0 anymore. – andyrandy Oct 28 '14 at 08:11
  • I did read quite a lot and to me it looks like it acts on a case by case basis but yeah, to be careful is good advice. Not the easiest API to deal with that's for sure – StudioTime Oct 28 '14 at 09:37