6

Is there a function in the Facebook.php library for getting friends of the user using a certain application. Something like:

$friends = $facebook->api('me/friends?access_token=' . $access_token);

But instead of listing all friends, it just lists friends using the same application.

diggersworld
  • 11,830
  • 21
  • 77
  • 115
  • 1
    I would like to have your problem :-) When I run this command in obj-c I get all friends, but I just want friends using the app...... figures.... I've been using "facebook.friends.getAppUsers" from the old REST API but now it seems to not be working in the latest API update - I'd like to use a command from the Graph API – Ryan Bavetta Oct 27 '10 at 09:32

2 Answers2

17

You should be able to do this with FQL:

select uid, name, is_app_user from user where uid in (select uid2 from friend where uid1=me()) and is_app_user=1
serg
  • 103,023
  • 70
  • 299
  • 324
  • Which function in the library to I pass the query to? – diggersworld Sep 21 '10 at 09:51
  • Like this? $fql_query = array( 'method' => 'fql.query', 'query' => 'select uid, name, is_app_user from user where uid in (select uid2 from friend where uid1=me()) and is_app_user=1' ); $fql_info = $facebook->api($fql_query); – diggersworld Sep 21 '10 at 09:53
  • @serg: No I get this error: Uncaught Exception: 104: Requires valid signature thrown in /mysite.com/src/facebook.php on line 413 – diggersworld Sep 23 '10 at 08:19
  • @diggersworld Are you passing access_token somewhere? Try to add it as a parameter to that array maybe. Sorry I am not very familiar with PHP API. – serg Sep 23 '10 at 15:08
  • 1
    I tried tinkering with the code but had no luck... So instead of using the library I'm doing it manually. Basically getting all the users friends from facebook, and then matching them with what's in my database system. – diggersworld Sep 30 '10 at 14:51
2

You can always make request with App token to url:

https://graph.facebook.com/user_id/friends?fields=id,name,installed

And then just filter user by installed param For user friends you can do the same but with client token.

Andrey Nikishaev
  • 3,493
  • 5
  • 36
  • 51
  • Hello...posting the same duplicate answer to multiple posts isn't really useful, especially when the questions are fairly old and already have accepted answers. This sort of activity looks slightly spammy to our community. Thanks. – Kev Oct 30 '12 at 23:27
  • 1
    there are two different topics with this problem(maybe more), and as i working with the same problem, i posted it. So this is not the spam. As for answer it's to old. – Andrey Nikishaev Oct 31 '12 at 12:25