我在我的 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/