iOS:获取好友列表

时间:2014-06-26 12:45:06

标签: ios objective-c facebook-sdk-3.0

我想通过facebook sdk获取朋友列表,我这样做:

- (IBAction)buttonTouched:(id)sender
{
    // If the session state is any of the two "open" states when the button is clicked
    if (FBSession.activeSession.state == FBSessionStateOpen
        || FBSession.activeSession.state == FBSessionStateOpenTokenExtended) {

        FBRequest* friendsRequest = [FBRequest requestForMyFriends];
        [friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                                      NSDictionary* result,
                                                      NSError *error) {

            NSLog(@"result:%@", result);

            friend_list_array = [[NSMutableArray alloc] initWithArray:[result objectForKey:@"data"]];
            FacebookChallengeViewController *facebook_V = [[FacebookChallengeViewController alloc] initWithNibName:@"FacebookChallengeViewController" bundle:nil withArray:friend_list_array];
            [facebook_V setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
            [facebook_V setModalPresentationStyle:UIModalPresentationFormSheet];
            [self presentViewController:facebook_V animated:YES completion:nil];
            facebook_V.view.superview.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
        }];

    } else {
        // Open a session showing the user the login UI
        // You must ALWAYS ask for basic_info permissions when opening a session
        [FBSession openActiveSessionWithReadPermissions:@[@"public_profile",@"user_friends"]
                                           allowLoginUI:YES
                                      completionHandler:
         ^(FBSession *session, FBSessionState state, NSError *error) {

             // Retrieve the app delegate
             AppDelegate* appDelegate =(AppDelegate*) [UIApplication sharedApplication].delegate;
             // Call the app delegate's sessionStateChanged:state:error method to handle session state changes
             [appDelegate sessionStateChanged:session state:state error:error];
         }];
    }
}

问题是“friend_list_array”只有接受te请求的人而不是我所有的朋友,问题是什么?

0 个答案:

没有答案