iOS facebook api - 获取 friend 的用户名

标签 ios objective-c facebook

我在我的 ios 应用程序中使用 Facebook api。 使用 FBFriendPickerViewController 的委托(delegate)方法:“shouldIncludeUser”,我尝试根据 FBGraphUser 对象的用户名属性过滤用户的好友列表。

问题是我不断获取 username 属性的空值,尽管该属性在文档中声明为不需要 access_key。

谢谢, 埃维亚塔尔

最佳答案

终于找到了! 显然 FBFriendPickerViewController 对象有一个名为:“fieldsForRequest”的属性。 使用此属性,我可以设置额外的属性以从服务器检索默认情况下不检索的属性。

就我而言,我只需要用户名属性:

FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init];
    friendPickerController.title = @"Pick Friends";
    friendPickerController.delegate = self;

    friendPickerController.fieldsForRequest = [NSSet setWithObjects:@"username", nil];

    [friendPickerController loadData];      
    // Use the modal wrapper method to display the picker.
    [friendPickerController presentModallyFromViewController:self animated:YES handler:
     ^(FBViewController *sender, BOOL donePressed) {
         if (!donePressed) {
             return;
         }


     }];

关于iOS facebook api - 获取 friend 的用户名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14790122/

相关文章:

ios - 我们可以定制facebook sdk框架吗?

ios - 使用 Facebook SDK 3.1 同时支持 iOS 5 和 iOS 6

ios - 如何订阅多个 Pusher 公共(public) channel ?

ios - Unity3D 4.1 导致 Everyplay 损坏 - "iPhone_GlesSupport.h"丢失

ios - UIViewContentModeScaleAspectFill 不保持图像的纵横比

iphone - 通过 presentModalViewController 添加 View 的自动旋转支持?

ios - RACCommand 初始值设定项信号未命中 executingSignals

ios - 如何在 iOS 中自己创建的模型类中使用泛型?

ios - 如何在实例方法中访问类方法变量或对两者使用公共(public)变量?

facebook - 在 IE 和 Azure 的 IFrame 中运行 Facebook 应用程序时,每个页面 View 上都会出现新 session