使用ios6在xcode 4.5中从facebook获取用户详细信息



我已经在我的应用程序中实现了集成facebook登录的概念。1---->我可以登录facebook,但在用户登录facebook后,我想继续使用我的应用程序,即出现一个带有三个选项卡项目的选项卡控制器,同时我需要获取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登录页面,我得到了tabarController,我无法获得检索用户的详细信息。

如何首先显示facebook登录页面,然后显示带有用户详细信息的选项卡控制器。?

您可以通过使用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

最新更新