这是我第一次尝试将 Facebook 集成到我的 ios 应用程序中。我正在尝试从 Facebook 导入名字、姓氏和其他一些详细信息。我可以登录 Facebook,但无法导入详细信息。我认为我的代码在某个地方是错误的,我不知道在哪里!
if (appDelegate.session.isOpen) {
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection,
id<FBGraphUser> user,
NSError *error2) {
regdet.firstname = user.first_name;
regdet.lastname = user.last_name;
regdet.email = [user objectForKey:@"email"];
regdet.address1 = [user objectForKey:@"locale"];
regdet.city = [user.location objectForKey:@"name"];
NSLog(@"firstname %@",regdet.firstname);
}];
} else {
if (appDelegate.session.state != FBSessionStateCreated) {
// Create a new, logged out session.
appDelegate.session = [[FBSession alloc] init];
}
// if the session isn't open, let's open it now and present the login UX to the user
[appDelegate.session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error1) {
[FBRequestConnection startForMeWithCompletionHandler:^(FBRequestConnection *connection,
id<FBGraphUser> user,
NSError *error2) {
regdet.firstname = user.first_name;
regdet.lastname = user.last_name;
regdet.email = [user objectForKey:@"email"];
regdet.address1 = [user objectForKey:@"locale"];
regdet.city = [user.location objectForKey:@"name"];
NSLog(@"firstname %@",regdet.firstname);
}];
[self performSegueWithIdentifier: @"Facebooksegue" sender: self];
}];
}