views:

1518

answers:

6

I have an application that uses the old REST API call Friends.getAppUsers to get the list of friends for the current user that have authorized my application.

I have read the docs, but I can't figure out how to do this with the Graph API. Can someone give me an example?

+1  A: 

Yes, the Graph API is horribly documented. I don't see any documentation for an "application" type, but they do reference an application's info in the docs:

https://graph.facebook.com/2439131959

So, perhaps you can get the application's members using the Group syntax?

https://graph.facebook.com/2439131959/members

You'll need an authenticated session to test it. Otherwise, it looks like Facebook is pushing us to use FQL to send queries directly:

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

You can execute FQL queries by fetching https://api.facebook.com/method/fql.query?query=QUERY. You can specify a response format as either XML or JSON with the format query parameter.

So you can pass a FQL query to get information about your application.

Typeoneerror
Ugh. Seems light switching to the graph api is more of a headache that I had originally hoped.
Richard
It's probably easier to do everything you need (except publishing) using FQL. The Graph API, at worst, won't give you everything you need, and at best, will make it irritatingly hard to find out how to do so.
Daniel Schaffer
+2  A: 

I've done a lot of investigating on this issue. From what I can tell there is no way to do Friends.getAppUsers using the graph API. The latest SDKs provided by facebook all use the old REST api to get friends using the app.

Richard
A: 

We really need a solution for this, the FQL query takes from 7-10 seconds to process using the new PHP SDK.

Yazeed Al Oyoun
Yes. It's incredibly slow. I have been thinking about caching the results for a period of time to keep from taking the performance hit every time I need the friend list.
Richard
A: 

The workaround is to do the filtering yourself. Presumably you have all the uid's of the users who have signed up for you app sitting in your own database. So first get all the users' friends' uids, and select the users from your DB who have matching uids.

The new facebook graph api program seems very poorly executed and not quite thought through. Seems they rushed to publish it by F8 before it was mature, and lots of functionality is missing that was available before.

schung
A: 

This can be done with FQL.

SELECT uid FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = ?)
AND is_app_user = 1

QED!

loungerdork
I originally used this query and because of the latency now I just get all friends via the graph api and then filter on my application side instead.
Richard
A: 

OLD REST API: $facebook->api_client->friends_getAppUsers();

NEW GRAPH API: $facebook->api(array('method' => 'friends.getAppUsers'));

enjoy :-)

jana
This SDK method call uses the old rest api under the covers. It's not the graph api :-(
Richard

related questions