[英]Friends Online Presence - Facebook SDK 3
Is it possible to find my friends online presence ( online,away or error ) with Facebook SDK? 是否有可能通过Facebook SDK找到我的朋友在线状态(在线,离开或错误)?
Using FQL I could do it like this: 使用FQL我可以这样做:
SELECT uid, name,pic_small,pic_big,online_presence FROM user
WHERE online_presence IN ('active') AND uid IN
(SELECT uid2 FROM friend WHERE uid1 = me())order by name
But is there a way to do it in facebook SDK, may be using something like this: 但是有没有办法在facebook SDK中做到这一点,可能会使用这样的东西:
[FBRequest requestForGraphPath:@"some/end/point/that/I/am/missing"]
Any help appreciated. 任何帮助赞赏。 Thanks.
谢谢。
Sorry for being late to post it here... I had solved this issue myself, here is my solution: 很抱歉迟到在这里发布...我自己解决了这个问题,这是我的解决方案:
- (void)getFriendsOnlinePresence
{
NSString* fql1 = [NSString stringWithFormat:@"SELECT uid,pic_square, name,online_presence FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY name"];
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
fql1, @"q",
nil];
[FBSession openActiveSessionWithAllowLoginUI:NO];
[FBRequestConnection startWithGraphPath:@"fql"
parameters:params
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"Result: %@", result);
}
}
//Notify via notification center
}];
}
If you can do it in FQL then getting it to work in the SDK is simply a matter of figuring out the right query. 如果你可以在FQL中完成它,那么让它在SDK中工作只需要找出正确的查询。 Your query
您的查询
SELECT uid, name,pic_small,pic_big,online_presence FROM user
WHERE online_presence IN ('active') AND uid IN
(SELECT uid2 FROM friend WHERE uid1 = me()) order by name
is executed as graph.facebook.com/fql?q=SELECT uid, name,pic_small,pic_big,online_presence FROM user WHERE online_presence IN ('active') AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by name
basically HTTP GET /fql?q=<QUERY>
执行为
graph.facebook.com/fql?q=SELECT uid, name,pic_small,pic_big,online_presence FROM user WHERE online_presence IN ('active') AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by name
基本上是HTTP GET /fql?q=<QUERY>
So I believe just need to set the path as fql
in requestForGraphPath
所以我认为只需要在
requestForGraphPath
中将路径设置为fql
FBRequest *fql = [FBRequest requestForGraphPath:@"fql"];
[fql.parameters setObject:@"SELECT uid, name,pic_small,pic_big,online_presence FROM user WHERE online_presence IN ('active') "
@"AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by name"
forKey:@"q"]
The latest documentation though shows examples with startWithGraphPath
under the FBRequestConnection
最新文档虽然显示了
startWithGraphPath
下的FBRequestConnection
NSString *query =
@"SELECT uid, name,pic_small,pic_big,online_presence FROM user WHERE online_presence IN ('active') "
@"AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) order by name";
// Set up the query parameter
NSDictionary *queryParam = @{ @"q": query };
// Make the API request that uses FQL
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:queryParam
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"Result: %@", result);
}
}];
Source: https://developers.facebook.com/docs/howtos/run-fql-queries-ios-sdk/ 资料来源: https : //developers.facebook.com/docs/howtos/run-fql-queries-ios-sdk/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.