问题描述
我如何看到我的哪些朋友参加了Facebook活动?我可以使用Facebook SDK获取所有与会者的列表,其中GraphPath:@eventId / attending /\".
How am I able to see which of my friends attend a Facebook event? I'm able to get a list of all attendees using the Facebook SDK, withGraphPath:@"eventId/attending/".
我甚至可以使用图表API?我读了一些关于如何使用FQL实现这一点的答案,但不知道如何在iOS中实现它。我想出的唯一选择是让所有的朋友和所有与会者相互交叉参考,但这是非常不方便的。
Is what I want even possible using the Graph API? I read some answers on how to achieve this with FQL but don't know how to implement it in iOS. The only option I came up with is getting all friends and all attendees and cross-referencing them against each other, but that is very inconvenient.
那么,如何才能让我的Facebook朋友参加活动?
So, how do I get only MY Facebook friends attending an event?
推荐答案
好的,所以我找到了我的问题的解决方案...通过FQL实现我想要的唯一方法。基本上,它会与参加者交叉引用您的朋友,但在Facebook服务器上,您只收到您要求的数据(在我的用例ID,名称,图像)。我没有想出如何设置限制和偏移量,但是我不需要它,我认为可以通过FQL来实现...
Okay, so I found the solution to my problem... The only way to achieve what I want is through FQL. Basically, it cross-references your friends with the attendees but on the Facebook servers, and you only receive the data you ask for (in my case user ID, name, image). I have not figured out how to set a limit and offset, but I don't require it and I think it is possible via FQL too...
这是我的代码:
-(void)getFriendsAttending{
NSLog(@"getting friends");
NSString *fql = [NSString stringWithFormat:@"SELECT uid, name, pic FROM user WHERE uid IN (SELECT uid FROM event_member WHERE eid = %@ AND rsvp_status = 'attending' AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()))", fbID];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"q"];
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:params
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (error) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"Friends at event %@: %@", fbID, result);
}
}];
}
这里是纯FQL查询的清晰度(123456789 - 作为事件ID):
And here is the pure FQL query for clarity (123456789 - being the event ID):
SELECT uid, name, pic FROM user WHERE uid IN (SELECT uid FROM event_member WHERE eid = 123456789 AND rsvp_status = 'attending' AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me()))
这篇关于获取Facebook朋友参加活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!