[英]How to know which Facebook friends of the user have my application installed?
是否可以执行以下操作? 我想创建一个 iOS 应用程序,它允许用户查看他们的所有 Facebook 朋友,这些朋友已经在他们的 Facebook 列表中拥有这个应用程序。 是否可以通过Facebook Connect或Graph API或其他方式实现?
是的,这是可能的。
如果您遵循了 Facebook 教程iOS 教程。
您应该可以访问AppDelegate.m
文件中的“facebook”object。 “facebook”object 已经用您的特定应用程序 ID 注册了。 然后您可以使用它来查询当前用户的已经安装了该应用程序的朋友。
这是检索朋友数据的 Facebook 查询:
NSString *fql = [NSString stringWithFormat:@"Select name, uid, pic_small from user where is_app_user = 1 and uid in (select uid2 from friend where uid1 = %@) order by concat(first_name,last_name) asc", _replace_this_with_the_fb_id_of_the_current_user_ ];
是的,您可以使用 GraphAPI 使用新的 Facebook SDK 3.5 及更高版本(2013 年 6 月)来完成。 您可以稍后根据需要使用 deviceFilteredFriends 可变数组...
// The Array for the filtered friends
NSMutableArray *installedFilteredFriends = [[NSMutableArray alloc] init];
// Request the list of friends of the logged in user (me)
[[FBRequest requestForGraphPath:@"me/friends?fields=installed"]
startWithCompletionHandler:
^(FBRequestConnection *connection,
NSDictionary *result,
NSError *error) {
// If we get a result with no errors...
if (!error && result)
{
// here is the result in a dictionary under a key "data"
NSArray *allFriendsResultData = [result objectForKey:@"data"];
if ([allFriendsResultData count] > 0)
{
// Loop through the friends
for (NSDictionary *friendObject in allFriendsResultData) {
// Check if installed data available
if ([friendObject objectForKey:@"installed"]) {
[installedFilteredFriends addObject: [friendObject objectForKey:@"id"]];
break;
}
}
}
}
}];
使用Facebook登录,然后请求该用户的好友。 您只会得到那些安装了请求应用程序的应用程序(它曾经返回所有带有“已安装”标志的朋友)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.