我正在尝试获取 FaceBook Friend list ,并将其显示在自定义视图中,例如“foresqure App”
我的意思是“foursquare”请求许可并在应用程序内的墙上发布而不将应用程序留给浏览器或应用程序 Facebook ?之后,应用程序获取所有朋友并将其显示在自定义 tableView 中。
这是我尝试过的:
if (!FBSession.activeSession.isOpen) {
// if the session is closed, then we open it here, and establish a handler for state changes
[FBSession openActiveSessionWithReadPermissions:@[@"public_profile", @"user_friends"]
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState state,
NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
} else if (session.isOpen) {
//[self pickFriendsButtonClick:sender];
NSLog(@"aaaa");
FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary* result,
NSError *error) {
NSArray* friends = [result objectForKey:@"data"];
NSLog(@"Found: %i friends", friends.count);
for (NSDictionary<FBGraphUser>* friend in friends) {
NSLog(@"I have a friend named %@ with id %@", friend.name, friend.id);
}
}];
}
}];
}
在这种情况下,它将打开 safari 以请求不在应用程序内部的权限,并且朋友数组允许 nill 或 count = 0。