1

是否可以执行以下操作?我想创建一个 iOS 应用程序,它允许用户查看他们的所有 Facebook 朋友,这些朋友已经在他们的 Facebook 列表中拥有这个应用程序。是否可以通过Facebook ConnectGraph API或其他方式实现?

4

4 回答 4

4

是的,这是可能的。

  1. 您需要维护自己的数据库,了解谁安装了该应用程序。
  2. 当用户安装应用程序时,他们通过其中一个 API 连接到 Facebook,获取他们的用户 ID,并将其提交到您的数据库,并带有用户安装应用程序的标志。
  3. 然后,您通过其中一个 API 向 Facebook 询问该用户的朋友 ID 列表,然后询问您的数据库是否有任何这些 ID 设置了相关的标志。
于 2012-04-06T12:01:28.923 回答
4

如果您遵循 Facebook 教程iOS 教程

您应该可以访问AppDelegate.m文件中的“facebook”对象。该“facebook”对象已经使用您的特定应用程序 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_ ];
于 2012-04-23T02:03:56.723 回答
0

是的,您可以使用 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;
                }
             }
          }
      }
 }];
于 2013-07-29T16:09:38.127 回答
0

使用 Facebook 登录,然后询问用户的朋友。您只会得到那些安装了请求应用程序的应用程序(它曾经返回所有带有“已安装”标志的朋友)

于 2015-11-10T13:45:56.050 回答