Facebook Friends.getAppUsers using Graph API

源自:http://stackoverflow.com/questions/2785093/facebook-friends-getappusers-using-graph-api


问:

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?


答:

http://stackoverflow.com/questions/2785093/facebook-friends-getappusers-using-graph-api






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!

link | edit
 
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  Oct 28 '10 at 17:03
 
Can you give more details about the latency? Is it the query taking too long to respond? I have been testing with a FB account with about 300+ friends and the response time has been a couple of seconds (2 to 4), which is not too bad IMO. –  loungerdork  Nov 1 '10 at 4:42
 
Yeah, that's roughly what I see. The graph API takes on the order of 500ms to return 400+ friends so I prefer to get them all and then filter on my side. –  Richard  Nov 2 '10 at 22:09
 
you can also use me() instead of the ? –  philfreo  yesterday
feedback

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

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

enjoy :-)

link | edit
 
1  
This SDK method call uses the old rest api under the covers. It's not the graph api :-( –  Richard  Oct 28 '10 at 17:02
feedback
up vote 5 down vote accepted

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.

link | edit
 
feedback

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.

link | edit
 
2  
Ugh. Seems light switching to the graph api is more of a headache that I had originally hoped. –  Richard May 20 '10 at 15:43
2  
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  Jul 1 '10 at 4:04
Was this post useful to you?      

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!

link | edit
 
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  Oct 28 '10 at 17:03
 
Can you give more details about the latency? Is it the query taking too long to respond? I have been testing with a FB account with about 300+ friends and the response time has been a couple of seconds (2 to 4), which is not too bad IMO. –  loungerdork  Nov 1 '10 at 4:42
 
Yeah, that's roughly what I see. The graph API takes on the order of 500ms to return 400+ friends so I prefer to get them all and then filter on my side. –  Richard  Nov 2 '10 at 22:09
 
you can also use me() instead of the ? –  philfreo  yesterday
feedback

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

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

enjoy :-)

link | edit
 
1  
This SDK method call uses the old rest api under the covers. It's not the graph api :-( –  Richard  Oct 28 '10 at 17:02
feedback
up vote 5 down vote accepted

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.

link | edit
 
feedback

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.

link | edit
 
2  
Ugh. Seems light switching to the graph api is more of a headache that I had originally hoped. –  Richard May 20 '10 at 15:43
2  
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  Jul 1 '10 at 4:04
Was this post useful to you?      

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!

link | edit
 
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  Oct 28 '10 at 17:03
 
Can you give more details about the latency? Is it the query taking too long to respond? I have been testing with a FB account with about 300+ friends and the response time has been a couple of seconds (2 to 4), which is not too bad IMO. –  loungerdork  Nov 1 '10 at 4:42
 
Yeah, that's roughly what I see. The graph API takes on the order of 500ms to return 400+ friends so I prefer to get them all and then filter on my side. –  Richard  Nov 2 '10 at 22:09
 
you can also use me() instead of the ? –  philfreo  yesterday
feedback

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

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

enjoy :-)

link | edit
 
1  
This SDK method call uses the old rest api under the covers. It's not the graph api :-( –  Richard  Oct 28 '10 at 17:02
feedback
up vote 5 down vote accepted

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.

link | edit
 
feedback

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.

link | edit
 
2  
Ugh. Seems light switching to the graph api is more of a headache that I had originally hoped. –  Richard May 20 '10 at 15:43
2  
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  Jul 1 '10 at 4:04
Was this post useful to you?      

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!

link | edit
 
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  Oct 28 '10 at 17:03
 
Can you give more details about the latency? Is it the query taking too long to respond? I have been testing with a FB account with about 300+ friends and the response time has been a couple of seconds (2 to 4), which is not too bad IMO. –  loungerdork  Nov 1 '10 at 4:42
 
Yeah, that's roughly what I see. The graph API takes on the order of 500ms to return 400+ friends so I prefer to get them all and then filter on my side. –  Richard  Nov 2 '10 at 22:09
 
you can also use me() instead of the ? –  philfreo  yesterday
feedback

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

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

enjoy :-)

link | edit
 
1  
This SDK method call uses the old rest api under the covers. It's not the graph api :-( –  Richard  Oct 28 '10 at 17:02
feedback
up vote 5 down vote accepted

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.

link | edit
 
feedback

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.

link | edit
 
2  
Ugh. Seems light switching to the graph api is more of a headache that I had originally hoped. –  Richard May 20 '10 at 15:43
2  
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  Jul 1 '10 at 4:04
Was this post useful to you?      
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值