如何使用Graph API在iphone中获得Facebook好友在线状态。

时间:2012-07-19 08:21:56

标签: iphone objective-c ios facebook-graph-api

我正在尝试使用Graph API获取所有在线朋友的列表。

我正在使用以下内容..

[facebook requestWithGraphPath:@"me/friends?fields=id,name,online_presence" andDelegate:self];

但这给了我0个结果。

感谢。

修改

我已经拥有从FB执行此操作的权限。

1 个答案:

答案 0 :(得分:2)

如果您正确配置了friends_online_presence权限,请尝试以下操作:

NSString* method = @"fql.query";
NSString* fql = @"SELECT uid, online_presence FROM user WHERE uid IN (SELECT uid2 FROM friend where uid1 = me())";
NSDictionary* params = [NSDictionary dictionaryWithObject: fql forKey: @"query"];

[[self facebook] requestWithMethodName: method
                             andParams: [params mutableCopy]
                         andHttpMethod: @"GET"
                           andDelegate: delegate];

这将返回一个在线状态的朋友列表:活动,空闲,离线或错误。