Facebook application user list

I am new to Facebook API. I want to get a list of my friends who also installed my application. (The idea is that you can start the game with them). A.

This gives a list of my friends:

FB.api('/me/friends', ... 

This gives information about my application:

 FB.api('/myappid', ... 

What I want is "my friends who also have this app installed"

I thought it could be like this:

 FB.api('/myappid/accounts', ... 

I was hoping to at least provide me with my developers, administrators, or testers, but that would not be such luck. http://developers.facebook.com/docs/test_users/ http://developers.facebook.com/docs/ApplicationSecurity/

My feeling, maybe I need to use FQL to construct a query that says something like

 (psuedocode) SELECT FROM my_friends WHERE uid IN ( SELECT uid FROM app_users WHERE appid = myappid ) 

Any advice is appreciated.

Notice, I saw this post: FaceBook application: get a list of user IDs of my application

I keep a local list of Facebook user IDs that belong to my site, and I can really achieve my goal by following these steps, but I'm sure there should be a better way:

 $facebookFriendIds = array(); $friends = $this->facebook->api('/me/friends'); foreach ($friends['data'] as $friend) { $facebookFriendIds[] = $friend['id']; } $this->friends = Doctrine_Core::getTable('User')->createQuery() ->whereIn('fb_user_id', $facebookFriendIds) ->execute(); 
+8
facebook facebook-graph-api facebook-fql
source share
2 answers

I suppose the FQL query

$facebook->api(array('method' => 'fql.query', 'query' => "SELECT uid FROM user WHERE is_app_user = '1' AND uid IN (SELECT uid2 FROM friend WHERE uid1 = '" . $user_id . "');"));

(I use java and the JS API, so the syntax may not be entirely accurate)

The documentation for user and friend requests is here:

http://developers.facebook.com/docs/reference/fql/user/

http://developers.facebook.com/docs/reference/fql/friend/

+9
source share

Use this query in JS

 function getAppFriends() { var fql = "SELECT uid, name, pic_square, is_app_user FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) OR uid IN(SELECT uid1 FROM friend WHERE uid2=me()) ORDER BY name"; var query = FB.Data.query(fql); query.wait(function(responseFromFb){ if(responseFromFb!=null){ // Read the responseFromFb and check for // is_app_user = true and list them out the way // you want to. } });// anonymus function closes here } //function ends here 
+1
source share

All Articles