1

我已经在我的应用程序中实现了 facebook 登录集成的概念。1---->我能够进行facebook登录,但在用户facebook登录后我想继续我的应用程序,即出现一个带有三个选项卡项目的tabbarController,同时我需要获取facebook用户详细信息(电子邮件、名字、姓氏等)

但我无法检索详细信息。我不明白我要去哪里错了。

在我的 ViewController.m 中:

- (IBAction)performLogin:(id)sender
{
    AppAppDelegate *appDelegate = (AppAppDelegate *) [[UIApplication sharedApplication] delegate];

    [appDelegate openSessionWithAllowLoginUI:YES];

    UITabBarController *tabBarController=[[UITabBarController alloc]init];
    SearchViewController *searchViewController=[[SearchViewController alloc]initWithNibName:@"SearchViewController" bundle:nil];

    UserProfile *userprofile=[[UserProfile alloc]initWithNibName:@"UserProfile" bundle:nil];
    userprofile.title=@"My Profile";

    LogOut *logout=[[LogOut alloc]initWithNibName:@"LogOut" bundle:nil];

    logout.title=@"Log Out";
    tabBarController.viewControllers=[NSArray arrayWithObjects:searchViewController,userprofile,logout, nil];

    [self presentModalViewController:tabBarController animated:YES];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(sessionStateChanged:)
                                                 name:FBSessionStateChangedNotification
                                               object:nil];
}

- (void)sessionStateChanged:(NSNotification*)notification {

    if (FBSession.activeSession.isOpen) {

        [FBRequestConnection
         startForMeWithCompletionHandler:^(FBRequestConnection *connection,
                                           id<FBGraphUser> user,
                                           NSError *error) {
             if (!error) {
                 NSString *fbUserEmail= @"";

                 NSLog(@"%@",user);

                 fbUserEmail=[user objectForKey:@"email"];

                 AppAppDelegate *appDelegate = (AppAppDelegate *) [[UIApplication sharedApplication] delegate];

                 appDelegate.fbEmail=fbUserEmail;
             }
         }
         ];
    }
}

但是在这里没有显示 facebook 登录页面,我得到了 tabbarController,我无法检索用户详细信息。

如何先显示 facebook 登录页面,然后显示 tabbarController 和用户详细信息。?

4

1 回答 1

4

您可以使用 Facebook Graph API 获取 facebook 用户详细信息,下面的链接演示了使用 Graph API 获取基本用户详细信息。在这里查看:http ://www.raywenderlich.com/1578/how-to-get-a-user-profile-with-facebooks-new-graph-api-from-your-iphone-app

于 2012-12-14T16:08:52.960 回答